C language provides many functions that come in header files to deal with allocating and managing memories. This tutorial will give brief information about managing memory in your program using some functions and their respective header files.

Management of Memory

Almost all programming languages can handle system memory. A program and all the variables used in the program occupy the precise memory space. Therefore, managing the memory with utmost care is one of the major tasks that the programmer should keep in mind while writing the code.

When a variable is assigned to memory in a program, that memory location cannot be used by another variable or any other program. So, the C language provides techniques for allocating memory for various variables and programs.

There are two types used for allocating memory. These are:

Static Memory Allocations

In the static memory allocation technique, memory allocation occurs at compile time and remains the same throughout the program. There will be no change in the amount of memory nor any change in the location of the memory.

Dynamic Memory Allocations

In the dynamic memory allocation technique, memory allocation occurs while running a program. It has the facility to increase/decrease the allocated memory quantity and can release or free up the memory whenever not needed or used. Memory can also be reallocated if needed. It is more beneficial, and it can manage memory efficiently.

Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram