2

Why is
Stack : Stored in Computer RAM like heap and
Heap : Stored in Computer RAM like stack ?

according to the nice answer by "Brain R Bondy" here

I am using Java language. Also what if i have too less RAM.

5
  • 3
    Where should these things be stored otherwise? Commented Oct 26, 2012 at 9:16
  • 1
    No stack and heap are on RAM thats fine but stack like heap and heap like stack, what do you mean by that ? Commented Oct 26, 2012 at 9:18
  • Have at look at these threads: stackoverflow.com/questions/362740/… and stackoverflow.com/questions/858250/…. Cheers, Commented Oct 26, 2012 at 9:19
  • 1
    I don't know what you mean by "stack like heap" that doesn't make sense and I don't see this statement in your linked answer. Commented Oct 26, 2012 at 9:21
  • The link which i have provided has this answer, its second answer from top and has 370 up-votes---- The user name is Brain R Bondy Commented Oct 26, 2012 at 9:27

3 Answers 3

2

Everything has to be stored in main memory (RAM) at some point, otherwise the CPU cannot work with it.

If you're running out of RAM, the operating system will outsource some of your application's memory to disk. This will make your program slow, but not break it. Because of this, the amount of memory your program can use does not depend on the amount of RAM that is physically available.

If you get stack overflow errors, you probably have an infinite recursion bug in your program.

If you get heap space/out of memory errors, see this question: What does Java option -Xmx stand for?

Sign up to request clarification or add additional context in comments.

Comments

1

To let the processor access them as fast as possible, because they are used a lot.

Comments

1

This means only, that they are both kept in the RAM.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.