Saturday, March 1, 2014

Difference Between Static Memory Allocation & Dynamic Memory Allocation



STATIC MEMORY ALLOCATION
DYNAMIC MEMORY ALLOCATION
Memory is allocated before the execution of the program begins (During Compilation).
Memory is allocated during the execution of the program.
Variables remain permanently allocated.
Allocated only when program unit is active.
In this type of allocation Memory cannot be resized after the initial allocation.
In this type of allocation Memory can be dynamically expanded and shrunk as necessary.
Implemented using stacks.
Implemented using heap.
Faster execution than Dynamic.
Slower execution than static.
It is less efficient than Dynamic allocation strategy.
It is more efficient than Static allocation strategy.
Implementation of this type of allocation is simple.
Implementation of this type of allocation is complicated.
Memory cannot be reuse when it is no longer needed.
Memory can be freed when it is no longer needed & reuse or reallocate during execution.

19 comments: