Compiler Design and Construction - Old Questions

10. What do you mean by runtime storage allocation? Differentiate static and dynamic allocation.

5 marks | Asked in Model Question

Runtime storage allocation

■ Compiler allocates space only for global variables at compile time

 Space for variables of procedures will be allocated at run-time

  • Stack/heap allocation
  • Ex: C, C++, Java, Fortran 8/9
  • Variable access is slow (compared to static allocation) since addresses are accessed through the stack/heap pointer
  • Recursion can be implemented

Difference between static and dynamic allocation:

Static allocation: Compiler makes the decision regarding storage allocation by looking only at the program text

Dynamic allocation: Storage allocation decisions are made only while the program is running.
Difference between static and dynamic allocation | Download Scientific  Diagram