You are on page 1of 19
11:36 AM | 92.7KB/s Zt © a 26 javatpoint.com/storag a Storage Organization en the tage rota ences han trans ns ow gies ates space in which he ve ef each progam has The lil acess space Is chared among the cogil, ofratng oye and target machine for management ard gonzon Tho epersing esta le ued to mip ho lagen drone it plyis asa wich i Uy =preod Subdivision of Run-time Memory: : i Sacer, ontne storage cores ito Hock, hare 2 yt see show the sles un of aterableemey Usb the our bytes machine werd can nn, Obet of mutes stared cote tye ne este iste adres, une stoage en be sti to od he tee components of an execu prota 1 oerested eecuble code 4. autem date cers stack @D> =e © For videos Join our Youtube Channel: Join Now Feedback Sed your Fedck to feeeckjvatycintcom Help Others, Please Share Leam Latest Tutorials, 2 9 &# Ss #@ g @ & RELA EAs eee O) eSpien Oc Storage Allocation Strategies in Compiler Design ‘A complies program that converts High-Level Language to LLL(Loe Level Languoge! ike machine language. na comple. there ts a ned for storage allocation svateplesin Compiler design because tis very important to Use the ight srategy for storage allocation as can deli afeet the performance ofthe software Storage Allocation Strategies “Tete are miny tee types of Storage Aocation Strateces: 2, Static Allocation 23, Steck Allocation 1. Static Allocation ‘Stati allocation lays ou or assigns the storage fr all the cata objects atthe compile time. In state location namoe aro bound t© storage. The address of these identifiers wail be the exme ‘throughout. The memory wal be allocated in sai leation one itis erated at compile te, C and C+ use state allocation For example int number = 17 static int digit = ‘Advantages of Static Allocation 4. eis easy to understand 2, The memory ie allocated once ony at compile time and remains tho came throughout the rogram completion, 3. Mamory allocation ie done before the program start taking memory nly on compile tine Disadvantages of Static altacation 4. Not highly scalable. 2, Static storage allocation isnt very ofcont. 23.The sie ofthe data must beknown atthe compe ime, 2. Heap Allocation Heap allocation i sed where the Stack allocation lacks if we want to retain the values ofthe local variable ater the activation record ends, which we cannot doin stack allocation, hee LIED scheme foes not work forthe alieation and d-slocation of the asvation recor Heap ete most exile storage allocation strteay we can dynamically allocate and de-allocate local variables whenever the user wants according to the user needs at runtime. The varablas in heap allocation can be changed according to the user's requrement. C+, Python an Jove all of these suppart Heap For example: (} 11:36 AM | 21.4KB/s 2 © GF tote Eyneieginenates Bate pentgson OS Cannes Ellegcontnign CP ‘Advantages of Heap Allocation 1. Heap allocation fe usefa when we have data whore sit ie not fred and can change dtng the 3. Heap allocation i the most fete allocation scheme Disadvantages of Heap Allceation 2. Heap allacaton i stoner a compare to stack allaeatn, 2, Theres» chance of memory lenks 23. Stack Allocation ‘tack & commonly known 2 memory a rant. Stack is» data structure thot follows the LIFO principle so whenever there it riitpleaetivation record created it wil be pushed or popped nthe stack as activations begin ant Dynamic allocation, Dynamic allocation means the allosten of ‘ends. Local varabies are bound to nest storage each time whenever the activation record begins because tne etorage ie allotted a untime every tne a procedure or function calli made. When the activation record gets popped cut, the local variable values get erased because the storage located forthe activation record removed, Cand C+ beth have supp for Steck allocation, For exemple: veld sun(int 2, int bp¢int ans = arb;coutscans:} 11 wen we call the sin funetion in che example above, enory will be allotted for the variable ans Conetusion In conelsion eliferent storage allocation strateces play an mportant rote in determining the best ie storage alloca rmemery is gong tobe allocates an desllocate, Different storage allectionstratgles have ther 3m strategy according tothe need of the user athe helps n determining how the ‘nm advantages and esadventages andthe choice depends onthe fotos ike speed, momery aacation.eiciency te. So we can choose the slieeatlon strategy aecerdng to the requirement Frequently Asked Questions (@.1: Whats the purpose of using storage allocation strategies in compiler design? 1m acompiter, theresa need for storage allocation strategies in Compiler design because tis very important to use the right etratagy for storage allocation 26 it can diracty affact the performance ofthe software (9.2: Which storage ellacation strategy is good if we compare Static nd Dynamic ‘Answer: It depends on many factors in some eases Static allocation vil be goed or in some cases allocated once only at compile tine and remains the same thoughout the program Dynan aloation, For example In state allocation, Its €38/ to undorsta completion 50 the exerution time will be contrlled. Wareas in Dynamic allocation the ‘memory allocation and ceallocaton are dynamic changes according tothe user requirement ‘So one can choose accordingly. Q.3: Whats Stack-based storage allocation? BCR Ls

You might also like