Memory
for the program execution is broadly divided into two areas, one for storing
user data called data area and other for storing program called program area.
Normally the contents of program area do not change during the execution of the
program. Data area stores the global or static constants or literals.
Example:
Printf
(“ The solution is = % d”, 426);
In
the above example the value 426 is constant and the string “The solution is =”
are to be stored in global area. Other than global variables, there will be
local variables whose value changes during the execution, these are to be
stored in area local of the particular function. For this purpose stacks are
used.
The runtime memory is divided into following parts.
a.
Code area to store target code
b.
Static data area – to store global variables or literals
c.
Stack area – to store activation record during procedure calls and return.
Stack Operates in LIFO fashion [Last In First Out]
d. Heap –
This is used for dynamic memory allocation.
Code area
|
Global/Static
area
|
Stack
|
Free space
|
Heap
|
Stack and
heap may have separate memory blocks or they may share the same memory area.
0 comments