0

I understand the fact that stack grows upwards and heap grows downwards or vice-versa (architecture dependent). But, i couldn't find much details about how actually it's implemented, my doubt is, for every process a memory block will be allocated, but is there a restriction on, how much max chunk can be used for stack or heap? Or are there no restrictions till whole allocated memory is consumed?

instance
  • 1,366
  • 15
  • 23

1 Answers1

0

Yes, processes have predetermined stack sizes. Have you ever tried to recurse a method/function too much? You get a StackOverflow exception. That doesn't mean you've already went through your entire computer's memory. The OS controls distribution of stack and heap memory for each process.

Naldhelaan
  • 390
  • 4
  • 13
  • **That doesn't mean you've already went through your entire computer's memory** -- I agree, but definitely memory chunk allocated for that process is exhausted. I belive StackOverflow occurs only when you have no more memory for that process only (not whole memory of system). – instance Jun 25 '15 at 13:02