Complete Computer Knowledge Portal

Thursday, April 4, 2013

Difference Between Static and Dynamic Memory Allocation



Characteristics
Static Memory Allocation
Dynamic Memory Allocation
Definition
It is Memory Allocation Technique in which Memory is allocated at compile-time before the associated program is executed.
It is the memory allocation Technique in Which memory is allocated as required at run-time.
lifetime of allocated memory
Static-duration variables are allocated in main memory, along with the executable code of the program, and persist for the lifetime of the program whether it is needed or not.
In Dynamic Memory Allocation allocated from the large pool of memory, which is called heap. In C, the library function malloc is used to
allocate a block of memory on the heap. The program accesses this block of memory via a pointer that malloc returns. When the memory is no longer needed, the pointer is passed to free which de allocates the memory so that it can be used for other purposes

No comments:

Post a Comment