Static allocation is a procedure which is used for allocation of all the data objects at compile time. Static allocation is possible only when the compiler knows the size of data object at compile time. In this type of allocation, formation of data objects is not possible under any circumstances at run time. In static allocation, compiler decides the amount of storage for each data object and binds the name of data objects to the allocated storage.
Stack allocation is a procedure in which stack is used to organize the storage. The stack used in stack allocation is known as control stack. In this type of allocation, creation of data objects is performed dynamically. In stack allocation, activation records are created for the allocation of memory. These activation records are pushed onto the stack using Last In First Out (LIFO) method. Locals are stored in the activation records at run time and memory addressing is done by using pointers and registers.
The difference between Static Allocation and Stack Allocation are as follows:
|S.No.||Static Allocation||Stack Allocation|
|1.||Static Allocation does not makes data structures and objects dynamically.||Stack allocation makes data structures and objects dynamically.|
|2.||In static allocation, allocation of all data objects is performed at compile time.||While in stack allocation, allocation of data objects is performed at run time.|
|3.||It does not support recursive procedures.||It supports recursive procedures.|
|4.||Static allocation is not able to manage the allocation of memory at run time.||Stack allocation use stack to manage the allocation of memory at run time.|
|5.||In static allocation, at compile time the data object names are fixed.||In stack allocation, index and registers performs the memory addressing.|
|6.||This strategy is easy and simple in implementing.||This strategy is slower than static allocation.|
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 Heap Allocation
- Stack vs Heap Memory Allocation
- Difference between Contiguous and Noncontiguous Memory Allocation
- First-Fit Allocation in Operating Systems
- Best-Fit Allocation in Operating System
- Resource Allocation Techniques for Processes
- Worst-Fit Allocation in Operating Systems
- Allocation of frames in Operating System
- Non-Contiguous Allocation in Operating System
- MCQ on Memory allocation and compilation process
- Channel Allocation Problem in Computer Network
- Resource Allocation Graph (RAG) in Operating System
- Buddy System - Memory allocation technique
- 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 Routing
- Difference between Static and Shared libraries
- Difference between Static and Dynamic IP address
- Difference between Static and Dynamic Web Pages
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.