1.

Explain memory allocation process in C.

Answer»
  • Memory allocation process indicates reserving some part of the memory space based on the requirement for the code execution.
  • There are two types of memory allocation done in C:
    1. Static memory allocation: The memory allocation during the beginning of the program is known as static memory allocation. In this TYPE of memory allocation allocated memory size remains fixed and it is not allowed to change the memory size during run-time. It will MAKE use of a stack for memory management.
    2. Dynamic memory allocation: The memory allocation during run-time is considered as dynamic memory allocation. We can mention the size at runtime as per requirement. It will make use of heap data structure for memory management. The REQUIRED memory space can be allocated and DEALLOCATED from heap memory. It is mainly used in pointers. Four types of the pre-defined FUNCTION that are used to dynamically allocate the memory are given below:
      • malloc()
      • calloc()
      • realloc()
      • free()


Discussion

No Comment Found