Static Allocation :
Static allocation is an allocation procedure which is used for allocation of all the data objects at compile time. In this type of allocation, allocation of data objects is done at compile time only. As in static allocation compiler decides the extent of storage which cannot be change with time, hence it is easy for the compiler to know the addresses of these data objects in the activation records at later stage. Static allocation is implemented in FORTRAN.
Heap Allocation :
Heap allocation is an allocation procedure in which heap is used to manage the allocation of memory. Heap helps in managing the dynamic memory allocation. In heap allocation, creation of dynamic data objects and data structures is also possible as same as stack allocation. Heap allocation overcomes the limitation of stack allocation. It is possible to retain the value of variables even after the activation record in heap allocation strategy which is not possible in stack allocation. It maintains a linked list for the free blocks and reuse the deallocated space using best fit.
The difference between Static Allocation and Heap Allocation are as follows:
|S.No.||Static Allocation||Heap Allocation|
|1.||Static allocation allocates memory on the basis of size of data objects.||Heap allocation make use of heap for managing the allocation of memory at run time.|
|2.||In static allocation, there is no possibility of creation of dynamic data structures and objects.||In heap allocation, dynamic data structures and objects are created.|
|3.||In static allocation, the names of the data objects are fixed with storage for addressing.||Heap allocation allocates contiguous block of memory to data objects.|
|4.||Static allocation is simple, but not efficient memory management technique.||Heap allocation does memory management in efficient way.|
|5.||Static allocation strategy is faster in accessing data as compared to heap allocation.||While heap allocation is slow in accessing as there is chance of creation of holes in reusing the free space.|
|6.||Static allocation is inexpensive, it is easy to implement.||While heap allocation is comparatively expensive.|
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Difference between Static allocation and Stack allocation
- Stack vs Heap Memory Allocation
- Difference between Contiguous and Noncontiguous Memory Allocation
- Best-Fit Allocation in Operating System
- First-Fit Allocation in Operating Systems
- Resource Allocation Techniques for Processes
- Worst-Fit Allocation in Operating Systems
- MCQ on Memory allocation and compilation process
- Allocation of frames in Operating System
- Non-Contiguous Allocation in Operating System
- Buddy System - Memory allocation technique
- Channel Allocation Problem in Computer Network
- Resource Allocation Graph (RAG) in Operating System
- Difference between static and non-static variables in Java
- Difference between Static-1 and Static-0 hazard
- Difference between Static and Dynamic SQL
- Difference between Static and Dynamic Hazard
- Difference between Static and Dynamic IP address
- Difference between Static and Shared libraries
- Difference between Static and Dynamic Routing
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.