Storage Allocation | Compiler Design - Computer Science Engineering (CSE) PDF Download

The different ways to allocate memory are:

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

Static Storage Allocation

  • In static allocation, names are bound to storage locations.
  • If memory is created at compile time then the memory will be created in static area and only once.
  • Static allocation supports the dynamic data structure that means memory is created only at compile time and deallocated after program completion.
  • The drawback with static storage allocation is that the size and position of data objects should be known at compile time.
  • Another drawback is restriction of the recursion procedure.

Stack Storage Allocation

  • In static storage allocation, storage is organized as a stack.
  • An activation record is pushed into the stack when activation begins and it is popped when the activation end.
  • Activation record contains the locals so that they are bound to fresh storage in each activation record. The value of locals is deleted when the activation ends.
  • It works on the basis of last-in-first-out (LIFO) and this allocation supports the recursion process.

Heap Storage Allocation

  • Heap allocation is the most flexible allocation scheme.
  • Allocation and deallocation of memory can be done at any time and at any place depending upon the user's requirement.
  • Heap allocation is used to allocate memory to the variables dynamically and when the variables are no more used then claim it back.
  • Heap storage allocation supports the recursion process.

Example:

fact (int n)  

{  

   if (n<=1)  

       return 1;  

   else   

       return (n * fact(n-1));  

}  

fact (6)

The dynamic allocation is as follows:
Storage Allocation | Compiler Design - Computer Science Engineering (CSE)

The document Storage Allocation | Compiler Design - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Compiler Design.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
Are you preparing for Computer Science Engineering (CSE) Exam? Then you should check out the best video lectures, notes, free mock test series, crash course and much more provided by EduRev. You also get your detailed analysis and report cards along with 24x7 doubt solving for you to excel in Computer Science Engineering (CSE) exam. So join EduRev now and revolutionise the way you learn!
Sign up for Free Download App for Free
26 videos|67 docs|30 tests

Up next

26 videos|67 docs|30 tests
Download as PDF

Up next

Explore Courses for Computer Science Engineering (CSE) exam
Related Searches

study material

,

ppt

,

practice quizzes

,

pdf

,

Viva Questions

,

Extra Questions

,

Free

,

Storage Allocation | Compiler Design - Computer Science Engineering (CSE)

,

shortcuts and tricks

,

Semester Notes

,

video lectures

,

Sample Paper

,

Previous Year Questions with Solutions

,

Exam

,

Objective type Questions

,

MCQs

,

Storage Allocation | Compiler Design - Computer Science Engineering (CSE)

,

Storage Allocation | Compiler Design - Computer Science Engineering (CSE)

,

mock tests for examination

,

Important questions

,

Summary

,

past year papers

;