Memory Management

One of the most important function of a programming language is to provide facilities for managing memory and the objects that are stored in memory.

C provides three distinct ways to allocate memory for objects:

Static memory allocation: 


Space for the objects provided in binary at compile time, these objects have extent (lifetime) as long as the binary which contains them loaded into the memory.

If i explain it in my simple word it means that it is the process of allocating memory at compile time before the program is executed.

Automatic memory allocation:


Temporary objects can be stored on the stack,and this space is automatically freed and reusable after the block in which they are declared is exited.

In automatic memory allocation, memory is allocated as required at run time.

Dynamic memory allocation:


Blocks of memory of arbitrary size can be requested at run-time using library functions.

In dynamic memory allocation, memory allocation is done at run-time.

 
Next PostNewer Post Previous PostOlder Post Home