0% found this document useful (0 votes)
17 views3 pages

Storage Allocation

Cd

Uploaded by

miniproject409
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Storage Allocation

Cd

Uploaded by

miniproject409
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
me enetunment WIN statable example. [EF storage Allocation Strategies ET TE DEE Ae Oe As we have already discussed that the run time storage is divided into 1. Code area 2. Static data area 3. Stack area 4. Heap area There are three different storaj time storage. The strategies are - Be allocation strategies based on this dives ‘sion of y vm, 1. Static allocation - The static allocation is for all the data Objects at compite tim, 2. Stack allocation - In the stack allocation a stack is used to manage then, storage. mm te 3. Heap allocation - 1 heap allocation the heap is used to manage the 4 memory allocation. Trang. Let us discuss each of these strategies in detail. [EZEE static altocation a. The size of data objects is known at compile time. The names of these Objects bound to storage at compile time only and such an allocation of data Gece 2 q done by static allocation. “9 b. The binding of name with the amount of storage allocated do not change at na time. Hence the name of this allocation is static allocation. ¢. In Static allocation the compiler can determine each data object. And therefore it becomes addresses of these data in the activation record. the amount of storage required by d. At compile time compiler can fill the addresses at which the target code can find | easy for-a compiler to find ie the data it operates on. e. FORTRAN uses the static allocation strategy. Limitations of static allocation 1. The static allocation can be done only if the size of data object is known at compile time. 2. The data structures can not be created dynamically. In the sense that, the static allocation can not manage the allocation of memory at run time. TECHNICAL PUBLICATIONS”. Aa up theust for kromledge egy isa str alled control stack ON beg COMPIetign ey PERS the activ S also ¢, ategy in which the storage is organized as stack. b.AS activation he ‘ation records are pushed onto the stack and on ‘ation the corresponding, activation records can be popped. in the each activation recor 7 record on each fresh activat Activ, c. The locals a, are stored corresponding activatio, ‘d. Hence locals are bound to tion. €S can be created dynamically for stack allocation. allocation The memor. ; Of alleen tttessing can be done using pointers and index registers. Hence this type ‘cation is slower than static allocation, [EEE Heap Allocation Limitations of stack local variables heap allocation strategy is used. b. The heap allocation allocates the continuous block of memory when required for storage of activation records or other data object. This allocated memory can be deallocated when activation ends. This deallocated (free) space can be further reused by heap manager. c. The efficient heap management can be done by i) Creating a linked list for the free blocks and when any memory is deallocated that block of memory is appended in the linked list. ii) Allocate the most suitable block of memory from the linked list. ie. use best fit technique for allocation of block. Ry Comparison between Static, Stack and Heap Allocation Stack allocation Heap allocation i eap allocation, heap is jon fs done In slack allocation, stack is In heap allosation Siete nae oe it used to manage guntime.. enor mapeatione ih ae objects a iptorage es once compile time. Static allocation § : knowieds? ceun at BUIBLICATIONS™- An up thrust for Compiler Design 6-6 Run Time Environman 2 Data structures can not Data structures and data —Data structures and data be created dynamically _ objects can be created objects can be created because in static dynamically. dynamically. | | allocation compiler can | determine the amount of storage required by each data object. 3. Memory allocation : The Memory allocation : Using” names of data objects are Last In First Out (LIFO) _ contiguous block of memory bound to storage at _ activation records and data_—_—_ from heap is allocated foe for compile time. _ objects are pushed onto the _ activation record or data “stack. The memory object. A linked list is addressing can be done maintained for free blocks. __using index and registers. _ Memory allocation : A Merits and limitations : Jt Merits and limitations : supports dynamic memory _ Efficient memory but it is slower management is done using than static allocation linked list. The deallocated only. Similarly recursive strategy. Supports recursive space can be reused. But procedures are not procedures but references to since memory block is supported by static _ non local variables after allocated using best fit, holes allocation strategy. "activation record can not be may get introduced in the i _ retained. | memory. This allocation strategy is simple to implement but supports static allocation —

You might also like