3 ms·
Stack was really meant to save parameters for function calls and local variables for functions or in your terms sub-routines. In a well organized program, usual
by mrjin 5y ago
Stack was really meant to save parameters for function calls and local variables for functions or in your terms sub-routines. In a well organized program, usually you would not need much stack space unless there was something went wrong, such as a recursive call without termination condition etc..
- feb 5y agoEven local variables of functions can take up a lot of room can take quite a lot of space. Especially when you minimize use of the heap. Using the stack instead of heap where possible makes for clean automatic free-ing of unused memory.
- IshKebab 5y ago> In a well organized program, usually you would not need much stack space But that's only because stack space is currently limited. If stack space were as unlimited as heap space then there would be absolutely nothing wrong with using as much stack space as you wanted. It would be better even - stack space is much quicker to allocate and free than heap space.