Mostly used for global variables and constants. They don't support recursive functions, nor do they allow dynamic arrays. Stack Storage Management Space for stack data objects is pushed and popped on a runtime stack at particular times during program execution, e.g. when procedures are called and when they return. More efficient use of space than static allocation. Good locality for virtual-memory systems and caches.
Most imperative languages use stack storage for data associated with activations.
Heap Storage Management Space for heap data objects can be allocated and deallocated at any time during program execution. The most flexible and expensive method of storage allocation. L ISP , ML and many interpreted languages need heap for activation records. Program variables and heap-allocated records form a directed graph. A node n is reachable if there is a path of directed edges starting at some root r .