Skip to main content

Static and dynamic memory allocation

Static memory allocation   

It refers to the allocation of memory during compilation of program.

Memory bindings are not established and destroyed during the execution

Variables remain permanently  
allocated.

Faster execution than dynamic.

More memory space required.

Data is stored in data segment of memory.

 

Dynamic memory allocation


It refers to the allocation of memory during execution of program.

Memory bindings are established and destroyed during the execution.

Allocated only when program unit is active.

Slower execution than static.

Less memory space required.

Data is stored in heap memory.


Comments