Storage Allocation in Block Structured Language


Storage Allocation in Block Structured Language

Storage Allocation in Block Structured Language is the easiest topic in computer science, In this article, you will learn easily Storage Allocation in Block Structured Language.

Storage Allocation in Block Structured Language
Storage Allocation in Block Structured Language

Storage allocation in Compiler Design

The different ways to allocate memory are:

  • Static storage allocation
  • Stack storage allocation
  • Heap storage allocation

Static storage allocation

  • Names are attached to storage locations in static allocation.
  • If memory is created at compile time, it will be created only once in the static field.
  • The dynamic data structure is supported by static allocation, which means memory is allocated only at compile time and released after the programme is finished.The disadvantage of static storage allocation is that data object size and place must be known at compile time.Another disadvantage is the recursion procedure’s limitation.

Stack Storage Allocation

  • Storage is structured as a stack of static storage allocation.
  • When activation starts, an activation record is placed into the stack, and when it ends, it is popped.
  • Locals are tied to fresh storage in each activation record since they are included in the activation record. When the activation is over, the value of locals is removed.
  • It operates on the last-in-first-out (LIFO) principle, and this allocation facilitates the recursion mechanism.

Heap Storage Allocation

  • The most versatile allocation scheme is heap allocation.
  • Memory allocation and deallocation can occur at any time and in any place, depending on the needs of the user.
  • Heap allocation is a technique for dynamically allocating memory to variables and then claiming it back when the variables are no longer in use.
  • The recursion mechanism is aided by heap storage allocation.


fact (int n)  
   if (n<=1)  
       return 1;  
       return (n * fact(n-1));  
fact (6)  

Storage Allocation


Please enter your comment!
Please enter your name here