Storage Allocation Strategies

Estudies4you
Storage Allocation Strategies:
There are three different storage allocation strategies based on runtime storage. They are:
  • Static Allocation
  • Stack Allocation
  • Heap Allocation
Static Allocation:
  • Storage is allocated at compile time
  • Static storage has fixed allocation that does not change during program execution
  • As bindings do not change at runtime, no runtime support is required
  • At compile time, compiler can fill the address at which the target code can find the data it operates on
  • FORTRAN uses the static allocation strategy
Limitations
  • Size of data objects should be known at compile time
  • Recursion is not supported
  • Data structures cannot be created at runtime
Stack Allocation
  • Stack allocation manages the runtime storage as a stack, i.e., control stack
  • Activation records are pushed and popped as activation begins and end respectively
  • Locals are always bound to fresh storage in each activation, because a new activation is onto a stack when a call is made
  • Values of locals are deleted as activation ends
  • The data structure can be created dynamically for stack allocation
Limitations
  • Values of locals cannot be retained once activation ends
  • The memory addressing can be done using pointers and indexed registers
  • This type of allocation is slower than static allocation
Heap allocation
  • Storage can be allocated and deallocated in any order
  • If the values of non-local variables must be retained even after the activation record then such a retaining is not possible by stack allocation
  • It is used for retaining of local variables
  • The heap allocation allocates the continuous block of memory when required for storage of activation records. This allocated memory can be deallocated when activation ends
  • Free space can be further reused by heap manager
  • It supports for recursion and data structures can be created at runtime
Limitation
  • Heap manages overhead.
Home


To Top