Thursday 2 February 2012

Concept of Heap and Stack


Concept of Heap and Stack


Local Variables

Stack

Free Memory
(Larger Memory Area than Stack).
Heap
Global Variables
Permanent Storage area
Program Instruction


The Program Instruction and Global and Static variables are stored in a region known as permanent storage area and the local variables are stored in another area called stack. The memory space located between these two regions is available for dynamic memory allocation during execution of program. This free memory region is called heap. The size of heap keeps on changing when program is executed due to creation and death of variables that are local to functions and blocks. Therefore, it is possible to encounter memory “overflow” during dynamic allocation process.

No comments:

Post a Comment