0% found this document useful (0 votes)
67 views2 pages

Storage Allocation

The document discusses three main storage allocation strategies: static allocation, stack allocation, and heap allocation. Static allocation is determined at compile time, stack allocation uses a control stack for managing local variables, and heap allocation allows for dynamic memory management. Each strategy has its advantages and limitations, particularly in terms of memory retention and efficiency.

Uploaded by

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

Storage Allocation

The document discusses three main storage allocation strategies: static allocation, stack allocation, and heap allocation. Static allocation is determined at compile time, stack allocation uses a control stack for managing local variables, and heap allocation allows for dynamic memory management. Each strategy has its advantages and limitations, particularly in terms of memory retention and efficiency.

Uploaded by

Lieo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

~ Allocadon St ra ~

.... \I '1•\1 1111 1/llfl / lfl"f ,,. \, .• f

,4S ..-e ha"' alrea dy di9c us.,e d that the run time storage 19 divid ed into :
code area
J.
, s,atiC data area
- s,ac1carea
~
,. Heaf'area
ion of run tinw
nwere are ~ different storage allocation strategies based on this divis
. • . .
.,age- 11'e str a~ are -
ts at compile time .
• _ s,anc allocation - The static allocation is for all the data objec
1
is used to manage the run time
2. stack allocation - In the stack allocation a stack
swrage.
man age the dyna mic memory
J. Heap allocation - In heap allocation the heap is used to
aDocation.
I.et us diSClJS6 each of thes e strategies in deta il

II seaac ADocation The nam es of these objects are


a. The siz.e of data obje cts is kno wn at compile time.
data objects is done by
bound to storage at compile time only and such an allocation of
slatic allocation.
b. The binding of nam e with the amo unt of storage alloc
ated do not change at run time.
Hence the nam e of this allocation is static allocation.
c. In static allocation the com piler can dete rmin e the
amo unt of storage required by t"IICh
find the addresses ol tlwse
data object. And therefore it becomes easy for a compiler to
data in the activation record.
d. At compile time compiler can fill the addr esse s at whic
h the target code can find the
data it operates on.

l '- IORTRAN uses the static allocation strategy.


r .
um 1ta lf, )O S O
I ,i. ,1 ;c al lo c• tlo n
lh• • ,1.11t, ,111,,,,111•11 ,.

11111,·
.
Ill l't' d,,m• ,111ly If lht•

, 1 bl ' l'r l',l lt• J


sl1t• or d,llil ot.Jt'<t ,. It
~
""""81
, n,,. .1.,1., ' I111• fll ll'~ ',l ll Jy na m ic al ly . In th e !M!nl
• ,
Ill
, .ill,l\:,lli t '
le '
Ill 11,11 ,n,111,l~l 11 on of m em or y a ru n tune. tha t
l II, ' •1 Ih ,, 1 \ ' H, • 8"
• r,, ,,h m ·~ ,11\' mil su pp or te
d by th111 ty pe o ( a IIuca fK>
' '
·' i-, ,-, ,r- ;\l ' I' n.

,; , "t ad , A ll, x· at.io n NIM?lllliiMHlH a


~-4~; ·~.Kio.. ,1lk,.:,1ti,m ~tr,1tcg . • CL
y is a strategy in which th
e sto ra ge is organiz.ed a
,t,k·lo.. 1, ,1 1~1 c,1lk'<i co
ntrol stack. ss~
t, ·-\, a ·ti\'ation begi
ns the activation record
•c,• ' . s ar e ~u sh ed on to th e
,:n rk tw n l1 f thIS ' · -
actwa 1!O il th e co rre sp onding activation re co rd s stack cllld
ca n be no n- ., 11
Th ' I :x:als ar c stored in .-- -ry,;u.
c. th e each activation re co
l'
cwrc-;p ' rd . H en ce locals are bound
onding activation record on
each fres h ac f1vatio n• I
J The data structures ca
n be created dynamically fo
r sta ck allocation.
Limitations of stack alloca
tion
The m em or y addressing ca
n be do ne us in g po in te rs
type of allocation is slo we r an d in de x registers. Henc
th an static allocation. e thi

S.4.3 Heap Allocation


a. 11 the values of no n loc
al variables m us t be re ta in
then such a retaining is ed ev en af te r th e activat
no t possible by sta ck al ion l'l'COld
allocation is because of its location. 1h is lim ita tio n
Last In First O ut of stack
na tu re . Fo r re ta in in g of su
he ap allocation strategy is ch local variables
used.
b. The heap allocation all
ocates the co nt in uo us bl
storage of activation reco ock of m em or y w he n
rds or ot he r da ta object. required for
dealiocated when activation Th ls al lo ca te d m em or y can be
en ds . This deallocated (free
he ap manager. ) sp ac e ca n be fu rth er reus
ed by
c. The efficient he ap m an
ag em en t can be do ne by
i) Creating a linked list _fo
r th e free .blocks an d w he
that block of m em or y 1s ap n an y m em or y is dealloc
pe nd ed m the lin ke d list. ated
ii) Allocate the mo~t su ita
. bl e block of m em or y from
leehn 1que 1o
1 th e lin k c'ti 1· t
r allocation of block. l IS . i.e. us e 1.
=- ;, fit
-t

You might also like