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?

1 Answer 1

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.

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

1 Comment

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).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.