Difference between Static v/s Dynamic memory allocation.
No. | Static Memory Allocation | Dynamic Memory Allocation |
1 | Memory is allocated before the execution of the program begins. | Memory is allocated during the execution of the program. |
2 | No memory allocation or de-allocation actions are performed during execution. | Memory Bindings are established and destroyed during the execution. |
3 | Variables remain permanently allocated. | Allocated only when program unit is active. |
4 | Implemented using stacks and heaps. | Implemented using data segments. |
5 | Pointer is needed to accessing variables. | No need of dynamically allocated pointers. |
6 | Faster execution than dynamic. | Slower execution than static. |
7 | More memory space required. | Less memory space required. |