apart from the stackwe also have memory pool known as heap heap memory is unused memory allocated to the program and available to be assigned during its execution when we dynamically allocate memory for variablesheap acts as memory pool from which memory is allocated to those variables howeverthis is just conceptual view of memory and implementation of the memory is entirely in the hands of system designers dynamic memory allocation the process of allocating memory to the variables during execution of the program or at run time is known as dynamic memory allocation language has four library routines which allow this function till now whenever we needed an array we had declared static array of fixed size as int arr[ ]when this statement is executedconsecutive space for integers is allocated it is not uncommon that we may be using only or of the allocated spacethereby wasting rest of the space to overcome this problem and to utilize the memory efficientlyc language provides mechanism of dynamically allocating memory so that only the amount of memory that is actually required is reserved we reserve space only at the run time for the variables that are actually required dynamic memory allocation gives best performance in situations in which we do not know memory requirements in advance provides four library routines to automatically allocate memory at the run time these routines are shown in table table memory allocation/de-allocation functions function task malloc(allocates memory and returns pointer to the first byte of allocated space calloc(allocates space for an array of elementsinitializes them to zero and returns pointer to the memory free(frees previously allocated memory realloc(alters the size of previously allocated memory when we have to dynamically allocate memory for variables in our programs then pointers are the only way to go when we use malloc(for dynamic memory allocationthen you need to manage the memory allocated for variables yourself memory allocations process in computer sciencethe free memory region is called heap the size of heap is not constant as it keeps changing when the program is executed in the course of program executionsome new variables are created and some variables cease to exist when the block in which they were declared is exited for this reason it is not uncommon to encounter memory overflow problems during dynamic allocation process when an overflow condition occursthe memory allocation functions mentioned above will return null pointer allocating block of memory let us see how memory is allocated using the malloc()function malloc is declared in so we include this header file in any program that calls malloc the malloc function reserves block