So I read that when a program is loaded on the main memory , it asscociates along with it static data , stack memory and heap memory. Wherein the stack generally grows downwards while the heap grows upwards. What I am confused about is since the stack is fixed in size how can it grow in the first place?
Asked
Active
Viewed 28 times
1
-
The stack *usage* grows in accordance with method calls. – user207421 Mar 29 '22 at 23:09
-
@user207421 , so does that mean , the stack memory is not constant or fixed in size? – Prakhar Shankar Mar 30 '22 at 13:57
-
The stack doesn't grow but its usage does. On Linux, the stack has a fixed of 8MB by default. Its usage by the process may grow but not its size. – user123 Mar 30 '22 at 18:50
-
@user123 does heap also behave simillarly? – Prakhar Shankar Mar 31 '22 at 15:06