Reputation: 608
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.
Upvotes: 2
Views: 337
Reputation: 15145
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?
Upvotes: 2
Reputation: 4160
To let the processor access them as fast as possible, because they are used a lot.
Upvotes: 1