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

CS 61 Lecture 3 - Sept 10

Uploaded by

raulmammadli132
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)
20 views3 pages

CS 61 Lecture 3 - Sept 10

Uploaded by

raulmammadli132
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/ 3

C ctvn3 September10,20

Storage lifetime and data layout Datarep3

qoootdcw png.IT 1 0
9
objects combinr
machine
code
ime

Void fine c 12 hex digits


inti o lifetime is only in these two brackets
avtomaticlitctr.hr
y
void f me C I 18 hex digits
i new int dynamics ends when
detected
gint freed c or program ends memory leak

include n.hn 16 hzx digits


ihti lifetime
global variable as
long as

the Program runs static.li rtime


void truce C 1
47
mem
data map
ta5xx 7 A xxx xxx
dynamic automatic
look into headump
lifetime trawl segment
general location
global static data change ul compile

hnlh.vn bloLk automatic stack


Mallocl free general location
new 1 delete dynamic heap changes w compiler
What rules do wmpih.rs use to choose locations
initializato
int 3 order

14 4 41 Ii fois anarai
charcz
Bx
047ft hexamp T sitygytjpf.fi nm

optimization quo
i3
into cc
c

I i gtfo
o
H
G padding
STALKFRAME Wmpihr Stones integers in mutts
automatic storage Ot Ll
for 1 function can

Sinsandmignment
Same for all objects of same type
Sit Sinot T of bytes required to hold rare
char I int 4
A
not a
Tequirement requirement

alignment aliquot T evenly divided object's


address
makes hardware better C accesses to medium sized
objects faster

Alignment Rules
alignment
char I 1

int 4 4 Size of CT is always a


8 g multiple of alignot t
long
pointers Tx 8 8 On X 86 64
Array i site alignment
T N size of CT N aliquot Ct
array
Struct
Struct T1 T2 ZZI.si notlTi max aliqnotlTil

AiqnwehtlM0Ithy for wheutions


array struct class union
1 First member law
Address of Wilemon address of first member
2 law
Array
element laid
are out
sequentially by index w no
gaps
1 array
vintptrt addle vintptrt array
vintptrt ei add rt i x size of CT
3 Strut rule
components of Simple Jthrtured am always laid out

in order of declaration There can be


padding
padding 2h bytes when int and char
alternating
16 bytes when
grouping into and then chars
situ of a structure is 2 site of the sum of its

Wmponents due to padding


Alignment Max alignment of an element

You might also like