<s>
Memory	O
management	O
is	O
a	O
form	O
of	O
resource	O
management	O
applied	O
to	O
computer	B-General_Concept
memory	I-General_Concept
.	O
</s>
<s>
This	O
is	O
critical	O
to	O
any	O
advanced	O
computer	O
system	O
where	O
more	O
than	O
a	O
single	O
process	B-Operating_System
might	O
be	O
underway	O
at	O
any	O
time	O
.	O
</s>
<s>
Virtual	B-Architecture
memory	I-Architecture
systems	O
separate	O
the	O
memory	O
addresses	O
used	O
by	O
a	O
process	B-Operating_System
from	O
actual	O
physical	O
addresses	O
,	O
allowing	O
separation	O
of	O
processes	O
and	O
increasing	O
the	O
size	O
of	O
the	O
virtual	B-General_Concept
address	I-General_Concept
space	I-General_Concept
beyond	O
the	O
available	O
amount	O
of	O
RAM	B-Architecture
using	O
paging	B-Architecture
or	O
swapping	O
to	O
secondary	O
storage	O
.	O
</s>
<s>
The	O
quality	O
of	O
the	O
virtual	B-Architecture
memory	I-Architecture
manager	O
can	O
have	O
an	O
extensive	O
effect	O
on	O
overall	O
system	O
performance	O
.	O
</s>
<s>
In	O
some	O
operating	B-General_Concept
systems	I-General_Concept
,	O
e.g.	O
</s>
<s>
OS/360	B-Application
and	I-Application
successors	I-Application
,	O
memory	O
is	O
managed	O
by	O
the	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
In	O
other	O
operating	B-General_Concept
systems	I-General_Concept
,	O
e.g.	O
</s>
<s>
Unix-like	B-Operating_System
operating	I-Operating_System
systems	I-Operating_System
,	O
memory	O
is	O
managed	O
at	O
the	O
application	O
level	O
.	O
</s>
<s>
Memory	O
management	O
within	O
an	O
address	B-General_Concept
space	I-General_Concept
is	O
generally	O
categorized	O
as	O
either	O
manual	B-Application
memory	I-Application
management	I-Application
or	O
automatic	B-General_Concept
memory	I-General_Concept
management	I-General_Concept
.	O
</s>
<s>
Memory	O
requests	O
are	O
satisfied	O
by	O
allocating	O
portions	O
from	O
a	O
large	O
pool	O
of	O
memory	O
called	O
the	O
heap	B-Application
or	O
free	O
store	O
.	O
</s>
<s>
At	O
any	O
given	O
time	O
,	O
some	O
parts	O
of	O
the	O
heap	B-Application
are	O
in	O
use	O
,	O
while	O
some	O
are	O
"	O
free	O
"	O
(	O
unused	O
)	O
and	O
thus	O
available	O
for	O
future	O
allocations	O
.	O
</s>
<s>
Several	O
issues	O
complicate	O
the	O
implementation	O
,	O
such	O
as	O
external	O
fragmentation	B-Architecture
,	O
which	O
arises	O
when	O
there	O
are	O
many	O
small	O
gaps	O
between	O
allocated	O
memory	O
blocks	O
,	O
which	O
invalidates	O
their	O
use	O
for	O
an	O
allocation	O
request	O
.	O
</s>
<s>
This	O
is	O
often	O
managed	O
by	O
chunking	B-General_Concept
.	O
</s>
<s>
that	O
there	O
are	O
no	O
"	O
memory	B-Error_Name
leaks	I-Error_Name
"	O
)	O
.	O
</s>
<s>
The	O
lowest	O
average	O
instruction	B-General_Concept
path	I-General_Concept
length	I-General_Concept
required	O
to	O
allocate	O
a	O
single	O
memory	O
slot	O
was	O
52	O
(	O
as	O
measured	O
with	O
an	O
instruction	O
level	O
profiler	O
on	O
a	O
variety	O
of	O
software	O
)	O
.	O
</s>
<s>
The	O
specific	O
algorithm	O
used	O
to	O
organize	O
the	O
memory	O
area	O
and	O
allocate	O
and	O
deallocate	O
chunks	O
is	O
interlinked	O
with	O
the	O
kernel	B-Operating_System
,	O
and	O
may	O
use	O
any	O
of	O
the	O
following	O
methods	O
:	O
</s>
<s>
Fixed-size	O
blocks	O
allocation	O
,	O
also	O
called	O
memory	O
pool	O
allocation	O
,	O
uses	O
a	O
free	B-General_Concept
list	I-General_Concept
of	O
fixed-size	O
blocks	O
of	O
memory	O
(	O
often	O
all	O
of	O
the	O
same	O
size	O
)	O
.	O
</s>
<s>
This	O
works	O
well	O
for	O
simple	O
embedded	B-Architecture
systems	I-Architecture
where	O
no	O
large	O
objects	O
need	O
to	O
be	O
allocated	O
,	O
but	O
suffers	O
from	O
fragmentation	B-Architecture
,	O
especially	O
with	O
long	O
memory	O
addresses	O
.	O
</s>
<s>
All	O
blocks	O
of	O
a	O
particular	O
size	O
are	O
kept	O
in	O
a	O
sorted	O
linked	B-Data_Structure
list	I-Data_Structure
or	O
tree	B-Application
and	O
all	O
new	O
blocks	O
that	O
are	O
formed	O
during	O
allocation	O
are	O
added	O
to	O
their	O
respective	O
memory	O
pools	O
for	O
later	O
use	O
.	O
</s>
<s>
One	O
of	O
the	O
resulting	O
parts	O
is	O
selected	O
,	O
and	O
the	O
process	B-Operating_System
repeats	O
until	O
the	O
request	O
is	O
complete	O
.	O
</s>
<s>
This	O
technique	O
alleviates	O
memory	B-Architecture
fragmentation	I-Architecture
and	O
is	O
efficient	O
as	O
there	O
is	O
no	O
need	O
to	O
search	O
for	O
a	O
suitable	O
portion	O
of	O
memory	O
,	O
as	O
any	O
open	O
slot	O
will	O
suffice	O
.	O
</s>
<s>
Many	O
Unix-like	B-Operating_System
systems	I-Operating_System
as	O
well	O
as	O
Microsoft	B-Application
Windows	I-Application
implement	O
a	O
function	O
called	O
for	O
dynamically	O
allocating	O
stack	O
memory	O
in	O
a	O
way	O
similar	O
to	O
the	O
heap-based	O
.	O
</s>
<s>
A	O
safer	O
version	O
of	O
alloca	O
called	O
,	O
which	O
reports	O
errors	O
,	O
exists	O
on	O
Microsoft	B-Application
Windows	I-Application
.	O
</s>
<s>
gnulib	B-Application
provides	O
an	O
equivalent	O
interface	O
,	O
albeit	O
instead	O
of	O
throwing	O
an	O
SEH	O
exception	O
on	O
overflow	O
,	O
it	O
delegates	O
to	O
malloc	O
when	O
an	O
overlarge	O
size	O
is	O
detected	O
.	O
</s>
<s>
In	O
many	O
programming	O
language	O
implementations	O
,	O
the	O
runtime	O
environment	O
for	O
the	O
program	O
automatically	O
allocates	O
memory	O
in	O
the	O
call	B-General_Concept
stack	I-General_Concept
for	O
non-static	O
local	O
variables	O
of	O
a	O
subroutine	O
,	O
called	O
automatic	B-General_Concept
variables	I-General_Concept
,	O
when	O
the	O
subroutine	O
is	O
called	O
,	O
and	O
automatically	O
releases	O
that	O
memory	O
when	O
the	O
subroutine	O
is	O
exited	O
.	O
</s>
<s>
Garbage	B-General_Concept
collection	I-General_Concept
is	O
a	O
strategy	O
for	O
automatically	O
detecting	O
memory	O
allocated	O
to	O
objects	O
that	O
are	O
no	O
longer	O
usable	O
in	O
a	O
program	O
,	O
and	O
returning	O
that	O
allocated	O
memory	O
to	O
a	O
pool	O
of	O
free	O
memory	B-General_Concept
locations	I-General_Concept
.	O
</s>
<s>
While	O
automatic	B-General_Concept
garbage	I-General_Concept
collection	I-General_Concept
has	O
the	O
advantages	O
of	O
reducing	O
programmer	O
workload	O
and	O
preventing	O
certain	O
kinds	O
of	O
memory	O
allocation	O
bugs	O
,	O
garbage	B-General_Concept
collection	I-General_Concept
does	O
require	O
memory	O
resources	O
of	O
its	O
own	O
,	O
and	O
can	O
compete	O
with	O
the	O
application	O
program	O
for	O
processor	O
time	O
.	O
</s>
<s>
Virtual	B-Architecture
memory	I-Architecture
is	O
a	O
method	O
of	O
decoupling	O
the	O
memory	O
organization	O
from	O
the	O
physical	O
hardware	O
.	O
</s>
<s>
Each	O
attempt	O
by	O
the	O
application	O
to	O
access	O
a	O
particular	O
virtual	B-General_Concept
memory	I-General_Concept
address	I-General_Concept
results	O
in	O
the	O
virtual	B-General_Concept
memory	I-General_Concept
address	I-General_Concept
being	O
translated	O
to	O
an	O
actual	O
physical	O
address	O
.	O
</s>
<s>
In	O
this	O
way	O
the	O
addition	O
of	O
virtual	B-Architecture
memory	I-Architecture
enables	O
granular	O
control	O
over	O
memory	O
systems	O
and	O
methods	O
of	O
access	O
.	O
</s>
<s>
In	O
virtual	B-Architecture
memory	I-Architecture
systems	O
the	O
operating	B-General_Concept
system	I-General_Concept
limits	O
how	O
a	O
process	B-Operating_System
can	O
access	O
the	O
memory	O
.	O
</s>
<s>
This	O
feature	O
,	O
called	O
memory	B-General_Concept
protection	I-General_Concept
,	O
can	O
be	O
used	O
to	O
disallow	O
a	O
process	B-Operating_System
to	O
read	O
or	O
write	O
to	O
memory	O
that	O
is	O
not	O
allocated	O
to	O
it	O
,	O
preventing	O
malicious	O
or	O
malfunctioning	O
code	O
in	O
one	O
program	O
from	O
interfering	O
with	O
the	O
operation	O
of	O
another	O
.	O
</s>
<s>
Shared	B-Operating_System
memory	I-Operating_System
is	O
one	O
of	O
the	O
fastest	O
techniques	O
for	O
inter-process	B-Operating_System
communication	I-Operating_System
.	O
</s>
<s>
IBM	B-Application
System/360	I-Application
does	O
not	O
support	O
virtual	B-Architecture
memory	I-Architecture
.	O
</s>
<s>
Memory	B-General_Concept
isolation	I-General_Concept
of	O
jobs	B-General_Concept
is	O
optionally	O
accomplished	O
using	O
protection	O
keys	O
,	O
assigning	O
storage	O
for	O
each	O
job	O
a	O
different	O
key	O
,	O
0	O
for	O
the	O
supervisor	B-Operating_System
or	O
1	O
–	O
15	O
.	O
</s>
<s>
Memory	O
management	O
in	O
OS/360	B-Application
is	O
a	O
supervisor	B-Operating_System
function	O
.	O
</s>
<s>
Storage	O
is	O
requested	O
using	O
the	O
GETMAIN	O
macro	O
and	O
freed	O
using	O
the	O
FREEMAIN	O
macro	O
,	O
which	O
result	O
in	O
a	O
call	O
to	O
the	O
supervisor	B-Operating_System
(	O
SVC	B-Operating_System
)	O
to	O
perform	O
the	O
operation	O
.	O
</s>
<s>
In	O
OS/360	B-Application
the	O
details	O
vary	O
depending	O
on	O
how	O
the	O
system	O
is	O
generated	B-Application
,	O
e.g.	O
,	O
for	O
PCP	O
,	O
MFT	O
,	O
MVT	O
.	O
</s>
<s>
In	O
OS/360	B-Application
MVT	O
,	O
suballocation	O
within	O
a	O
job	O
's	O
region	O
or	O
the	O
shared	O
System	O
Queue	O
Area	O
(	O
SQA	O
)	O
is	O
based	O
on	O
subpools	O
,	O
areas	O
a	O
multiple	O
of	O
2KB	O
in	O
size	O
—	O
the	O
size	O
of	O
an	O
area	O
protected	O
by	O
a	O
protection	O
key	O
.	O
</s>
<s>
Within	O
a	O
region	O
subpools	O
are	O
assigned	O
either	O
the	O
job	O
's	O
storage	B-General_Concept
protection	I-General_Concept
or	O
the	O
supervisor	B-Operating_System
's	O
key	O
,	O
key	O
0	O
.	O
</s>
<s>
Subpools	O
250	O
–	O
255	O
are	O
created	O
by	O
memory	O
requests	O
by	O
the	O
supervisor	B-Operating_System
on	O
behalf	O
of	O
the	O
job	O
.	O
</s>
<s>
The	O
details	O
for	O
OS/VS1	B-Application
are	O
similar	O
to	O
those	O
for	O
MFT	O
and	O
for	O
MVT	O
;	O
the	O
details	O
for	O
OS/VS2	B-Application
are	O
similar	O
to	O
those	O
for	O
MVT	O
,	O
except	O
that	O
the	O
page	O
size	O
is	O
4	O
KiB	O
.	O
</s>
<s>
For	O
both	O
OS/VS1	B-Application
and	O
OS/VS2	B-Application
the	O
shared	O
System	O
Queue	O
Area	O
(	O
SQA	O
)	O
is	O
nonpageable	O
.	O
</s>
<s>
In	O
MVS	B-Application
the	O
address	B-General_Concept
space	I-General_Concept
includes	O
an	O
additional	O
pageable	O
shared	O
area	O
,	O
the	O
Common	O
Storage	O
Area	O
(	O
CSA	O
)	O
,	O
and	O
an	O
additional	O
private	O
area	O
,	O
the	O
System	O
Work	O
area	O
(	O
SWA	O
)	O
.	O
</s>
