<s>
In	O
computing	O
,	O
a	O
data	B-General_Concept
segment	I-General_Concept
(	O
often	O
denoted	O
.data	B-General_Concept
)	O
is	O
a	O
portion	O
of	O
an	O
object	B-Application
file	I-Application
or	O
the	O
corresponding	O
address	B-General_Concept
space	I-General_Concept
of	O
a	O
program	O
that	O
contains	O
initialized	O
static	B-General_Concept
variables	I-General_Concept
,	O
that	O
is	O
,	O
global	O
variables	O
and	O
static	O
local	O
variables	O
.	O
</s>
<s>
The	O
size	O
of	O
this	O
segment	O
is	O
determined	O
by	O
the	O
size	O
of	O
the	O
values	O
in	O
the	O
program	O
's	O
source	O
code	O
,	O
and	O
does	O
not	O
change	O
at	O
run	B-Library
time	I-Library
.	O
</s>
<s>
The	O
data	B-General_Concept
segment	I-General_Concept
is	O
read/write	O
,	O
since	O
the	O
values	O
of	O
variables	O
can	O
be	O
altered	O
at	O
run	B-Library
time	I-Library
.	O
</s>
<s>
This	O
is	O
in	O
contrast	O
to	O
the	O
read-only	B-General_Concept
data	I-General_Concept
segment	I-General_Concept
(	O
segment	O
or	O
.rodata	B-General_Concept
)	O
,	O
which	O
contains	O
static	O
constants	O
rather	O
than	O
variables	O
;	O
it	O
also	O
contrasts	O
to	O
the	O
code	B-General_Concept
segment	I-General_Concept
,	O
also	O
known	O
as	O
the	O
text	B-General_Concept
segment	I-General_Concept
,	O
which	O
is	O
read-only	O
on	O
many	O
architectures	O
.	O
</s>
<s>
Uninitialized	O
data	O
,	O
both	O
variables	O
and	O
constants	O
,	O
is	O
instead	O
in	O
the	O
BSS	B-General_Concept
segment	I-General_Concept
.	O
</s>
<s>
Historically	O
,	O
to	O
be	O
able	O
to	O
support	O
memory	O
address	B-General_Concept
spaces	I-General_Concept
larger	O
than	O
the	O
native	O
size	O
of	O
the	O
internal	O
address	O
register	O
would	O
allow	O
,	O
early	O
CPUs	O
implemented	O
a	O
system	O
of	O
segmentation	B-General_Concept
whereby	O
they	O
would	O
store	O
a	O
small	O
set	O
of	O
indexes	O
to	O
use	O
as	O
offsets	O
to	O
certain	O
areas	O
.	O
</s>
<s>
The	O
Intel	B-General_Concept
8086	I-General_Concept
family	O
of	O
CPUs	O
provided	O
four	O
segments	O
:	O
the	O
code	B-General_Concept
segment	I-General_Concept
,	O
the	O
data	B-General_Concept
segment	I-General_Concept
,	O
the	O
stack	B-Application
segment	O
and	O
the	O
extra	O
segment	O
.	O
</s>
<s>
A	O
computer	O
program	B-Device
memory	I-Device
can	O
be	O
largely	O
categorized	O
into	O
two	O
sections	O
:	O
read-only	O
and	O
read/write	O
.	O
</s>
<s>
This	O
distinction	O
grew	O
from	O
early	O
systems	O
holding	O
their	O
main	O
program	O
in	O
read-only	B-Device
memory	I-Device
such	O
as	O
Mask	B-Device
ROM	I-Device
,	O
EPROM	B-General_Concept
,	O
PROM	B-General_Concept
or	O
EEPROM	B-General_Concept
.	O
</s>
<s>
As	O
systems	O
became	O
more	O
complex	O
and	O
programs	O
were	O
loaded	O
from	O
other	O
media	O
into	O
RAM	O
instead	O
of	O
executing	O
from	O
ROM	B-Device
,	O
the	O
idea	O
that	O
some	O
portions	O
of	O
the	O
program	O
's	O
memory	O
should	O
not	O
be	O
modified	O
was	O
retained	O
.	O
</s>
<s>
These	O
became	O
the	O
.text	B-General_Concept
and	O
.rodata	B-General_Concept
segments	O
of	O
the	O
program	O
,	O
and	O
the	O
remainder	O
which	O
could	O
be	O
written	O
to	O
divided	O
into	O
a	O
number	O
of	O
other	O
segments	O
for	O
specific	O
tasks	O
.	O
</s>
<s>
The	O
code	B-General_Concept
segment	I-General_Concept
,	O
also	O
known	O
as	O
text	B-General_Concept
segment	I-General_Concept
,	O
contains	O
executable	B-Application
code	I-Application
and	O
is	O
generally	O
read-only	O
and	O
fixed	O
size	O
.	O
</s>
<s>
The	O
data	B-General_Concept
segment	I-General_Concept
contains	O
initialized	O
static	B-General_Concept
variables	I-General_Concept
,	O
i.e.	O
</s>
<s>
global	O
variables	O
and	O
local	O
static	B-General_Concept
variables	I-General_Concept
which	O
have	O
a	O
defined	O
value	O
and	O
can	O
be	O
modified	O
.	O
</s>
<s>
The	O
BSS	B-General_Concept
segment	I-General_Concept
contains	O
uninitialized	O
static	O
data	O
,	O
both	O
variables	O
and	O
constants	O
,	O
i.e.	O
</s>
<s>
global	O
variables	O
and	O
local	O
static	B-General_Concept
variables	I-General_Concept
that	O
are	O
initialized	O
to	O
zero	O
or	O
do	O
not	O
have	O
explicit	O
initialization	O
in	O
source	O
code	O
.	O
</s>
<s>
The	O
heap	O
segment	O
contains	O
dynamically	O
allocated	O
memory	O
,	O
commonly	O
begins	O
at	O
the	O
end	O
of	O
the	O
BSS	B-General_Concept
segment	I-General_Concept
and	O
grows	O
to	O
larger	O
addresses	O
from	O
there	O
.	O
</s>
<s>
It	O
is	O
managed	O
by	O
malloc	B-Language
,	O
calloc	B-Language
,	O
realloc	B-Language
,	O
and	O
free	O
,	O
which	O
may	O
use	O
the	O
brk	B-General_Concept
and	O
sbrk	B-General_Concept
system	O
calls	O
to	O
adjust	O
its	O
size	O
(	O
note	O
that	O
the	O
use	O
of	O
brk/sbrk	O
and	O
a	O
single	O
heap	O
segment	O
is	O
not	O
required	O
to	O
fulfill	O
the	O
contract	O
of	O
malloc/calloc/realloc/free	O
;	O
they	O
may	O
also	O
be	O
implemented	O
using	O
mmap/munmap	O
to	O
reserve/unreserve	O
potentially	O
non-contiguous	O
regions	O
of	O
virtual	O
memory	O
into	O
the	O
process	O
 '	O
virtual	B-General_Concept
address	I-General_Concept
space	I-General_Concept
)	O
.	O
</s>
<s>
The	O
stack	B-Application
segment	O
contains	O
the	O
call	B-General_Concept
stack	I-General_Concept
,	O
a	O
LIFO	B-Application
structure	O
,	O
typically	O
located	O
in	O
the	O
higher	O
parts	O
of	O
memory	O
.	O
</s>
<s>
A	O
"	O
stack	B-Application
pointer	O
"	O
register	O
tracks	O
the	O
top	O
of	O
the	O
stack	B-Application
;	O
it	O
is	O
adjusted	O
each	O
time	O
a	O
value	O
is	O
"	O
pushed	O
"	O
onto	O
the	O
stack	B-Application
.	O
</s>
<s>
The	O
set	O
of	O
values	O
pushed	O
for	O
one	O
function	O
call	O
is	O
termed	O
a	O
"	O
stack	B-Application
frame	O
"	O
.	O
</s>
<s>
A	O
stack	B-Application
frame	O
consists	O
at	O
minimum	O
of	O
a	O
return	O
address	O
.	O
</s>
<s>
Automatic	B-General_Concept
variables	I-General_Concept
are	O
also	O
allocated	O
on	O
the	O
stack	B-Application
.	O
</s>
<s>
The	O
stack	B-Application
segment	O
traditionally	O
adjoined	O
the	O
heap	O
segment	O
and	O
they	O
grew	O
towards	O
each	O
other	O
;	O
when	O
the	O
stack	B-Application
pointer	O
met	O
the	O
heap	O
pointer	O
,	O
free	O
memory	O
was	O
exhausted	O
.	O
</s>
<s>
With	O
large	O
address	B-General_Concept
spaces	I-General_Concept
and	O
virtual	O
memory	O
techniques	O
they	O
tend	O
to	O
be	O
placed	O
more	O
freely	O
,	O
but	O
they	O
still	O
typically	O
grow	O
in	O
a	O
converging	O
direction	O
.	O
</s>
<s>
On	O
the	O
standard	O
PC	O
x86	B-Operating_System
architecture	I-Operating_System
the	O
stack	B-Application
grows	O
toward	O
address	O
zero	O
,	O
meaning	O
that	O
more	O
recent	O
items	O
,	O
deeper	O
in	O
the	O
call	B-General_Concept
chain	I-General_Concept
,	O
are	O
at	O
numerically	O
lower	O
addresses	O
and	O
closer	O
to	O
the	O
heap	O
.	O
</s>
<s>
Some	O
interpreted	O
languages	O
offer	O
a	O
similar	O
facility	O
to	O
the	O
data	B-General_Concept
segment	I-General_Concept
,	O
notably	O
Perl	B-Language
and	O
Ruby	B-Language
.	O
</s>
<s>
In	O
these	O
languages	O
,	O
including	O
the	O
line	O
__DATA__	O
(	O
Perl	B-Language
)	O
or	O
__END__	O
(	O
Ruby	B-Language
,	O
old	O
Perl	B-Language
)	O
marks	O
the	O
end	O
of	O
the	O
code	B-General_Concept
segment	I-General_Concept
and	O
the	O
start	O
of	O
the	O
data	B-General_Concept
segment	I-General_Concept
.	O
</s>
<s>
Only	O
the	O
contents	O
prior	O
to	O
this	O
line	O
are	O
executed	O
,	O
and	O
the	O
contents	O
of	O
the	O
source	O
file	O
after	O
this	O
line	O
are	O
available	O
as	O
a	O
file	O
object	O
:	O
PACKAGE::DATA	O
in	O
Perl	B-Language
(	O
e.g.	O
,	O
main::DATA	O
)	O
and	O
DATA	O
in	O
Ruby	B-Language
.	O
</s>
