1 Answer

No, activation records for functions (i.e. local or automatic variables) are allocated on the stack that is used not only to store these variables, but also keep track of nested function calls.

How the heap is managed is really up to the run-time environment. C uses malloc and C++ uses new, but many other languages have garbage collection.

However, the stack is more low level feature closely tied to the processor architecture. Growing the heap when there is not enough space isn't too hard since it can be implemented in the library call that handles the heap. However, growing the stack is often impossible as the stack overflow only is discovered when it is too late and shutting down the thread of execution is the only viable option.