Static Memory Allocation
- In this case, variables get allocated permanently
- Allocation is done before program execution (compile time)
- It uses the data structure called stack for implementing static allocation
- Less efficient
- There is no memory reusability
Example: primitive data type
| Dynamic Memory Allocation
- In this case, variables get allocated only if your program unit gets active
- Allocation is done during program execution (run time)
- It uses the data structure called heap for implementing dynamic allocation
- More efficient
- There is memory reusability and memory can be freed when not required
Example: object, pointer variable
|
0 Comments