Header Ads Widget

Ticker

6/recent/ticker-posts

Difference between Static and Dynamic Memory Allocation

Difference between Static and Dynamic Memory Allocation
Memory allocation in programming is very important for storing values when you assign them to variables. The allocation is done either before or at the time of program execution. This eventually allocates memory for the variables declared by a programmer via the compiler.

The major difference between static and dynamic memory allocations are:

Difference between Static and Dynamic Memory Allocation

Static Memory AllocationDynamic Memory Allocation
In this case, variables get allocated permanently.In this case, variables get allocated only if your program unit gets active.
Allocation is done before program execution.Allocation is done during program execution.
It uses the data structure called stack for implementing static allocationIt uses the data structure called heap for implementing dynamic allocation
Less efficient.More efficient.
There is no memory re-usability.There is memory reusability and memory can be freed when not required.

Post a Comment

0 Comments