DYNAMIC MEMORY ALLOCATION
The memory allocation may be classified as static memory
allocation and dynamic memory allocation.
Static
memory allocation: Memory for the variables
is created at the time of compilation is known as static memory.
Dynamic
memory allocation: Memory for the
variables is allocated at the time of execution of the program is called
dynamic memory. The following functions
are used for dynamic memory allocation which are defined in stdlib.h and alloc.h header files.
1. malloc() 2.
calloc() 3. realloc() 4. free()
malloc(), calloc() and
realloc() are memory allocation functions and free() is a memory
releasing function.
The program instructions, global and static variables are
stored in a region known as permanent
storage area. Local variables
are stored in another region called stack. The memory spaced located between stack and
permanent storage area is available for dynamic memory allocation during
execution of the program. This free
memory region is called as heap.
No comments:
Post a Comment