<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
tracing	B-General_Concept
garbage	I-General_Concept
collection	I-General_Concept
is	O
a	O
form	O
of	O
automatic	B-General_Concept
memory	I-General_Concept
management	I-General_Concept
that	O
consists	O
of	O
determining	O
which	O
objects	O
should	O
be	O
deallocated	O
(	O
"	O
garbage	B-General_Concept
collected	I-General_Concept
"	O
)	O
by	O
tracing	O
which	O
objects	O
are	O
reachable	O
by	O
a	O
chain	O
of	O
references	O
from	O
certain	O
"	O
root	O
"	O
objects	O
,	O
and	O
considering	O
the	O
rest	O
as	O
"	O
garbage	O
"	O
and	O
collecting	O
them	O
.	O
</s>
<s>
Tracing	B-General_Concept
garbage	I-General_Concept
collection	I-General_Concept
is	O
the	O
most	O
common	O
type	O
of	O
garbage	B-General_Concept
collection	I-General_Concept
–	O
so	O
much	O
so	O
that	O
"	O
garbage	B-General_Concept
collection	I-General_Concept
"	O
often	O
refers	O
to	O
tracing	B-General_Concept
garbage	I-General_Concept
collection	I-General_Concept
,	O
rather	O
than	O
other	O
methods	O
such	O
as	O
reference	B-General_Concept
counting	I-General_Concept
–	O
and	O
there	O
are	O
a	O
large	O
number	O
of	O
algorithms	O
used	O
in	O
implementation	O
.	O
</s>
<s>
Typically	O
,	O
these	O
include	O
all	O
the	O
objects	O
referenced	O
from	O
anywhere	O
in	O
the	O
call	B-General_Concept
stack	I-General_Concept
(	O
that	O
is	O
,	O
all	O
local	O
variables	O
and	O
parameters	O
in	O
the	O
functions	O
currently	O
being	O
invoked	O
)	O
,	O
and	O
any	O
global	O
variables	O
.	O
</s>
<s>
The	O
problem	O
of	O
precisely	O
identifying	O
semantic	O
garbage	O
can	O
easily	O
be	O
shown	O
to	O
be	O
partially	O
decidable	O
:	O
a	O
program	O
that	O
allocates	O
an	O
object	O
X	O
,	O
runs	O
an	O
arbitrary	O
input	O
program	O
P	O
,	O
and	O
uses	O
X	O
if	O
and	O
only	O
if	O
P	O
finishes	O
would	O
require	O
a	O
semantic	O
garbage	B-General_Concept
collector	I-General_Concept
to	O
solve	O
the	O
halting	O
problem	O
.	O
</s>
<s>
Although	O
conservative	O
heuristic	B-Algorithm
methods	O
for	O
semantic	O
garbage	O
detection	O
remain	O
an	O
active	O
research	O
area	O
,	O
essentially	O
all	O
practical	O
garbage	B-General_Concept
collectors	I-General_Concept
focus	O
on	O
syntactic	O
garbage	O
.	O
</s>
<s>
Another	O
complication	O
with	O
this	O
approach	O
is	O
that	O
,	O
in	O
languages	O
with	O
both	O
reference	B-Language
types	I-Language
and	O
unboxed	O
value	O
types	O
,	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
needs	O
to	O
somehow	O
be	O
able	O
to	O
distinguish	O
which	O
variables	O
on	O
the	O
stack	O
or	O
fields	O
in	O
an	O
object	O
are	O
regular	O
values	O
and	O
which	O
are	O
references	O
:	O
in	O
memory	O
,	O
an	O
integer	O
and	O
a	O
reference	O
might	O
look	O
alike	O
.	O
</s>
<s>
The	O
garbage	B-General_Concept
collector	I-General_Concept
then	O
needs	O
to	O
know	O
whether	O
to	O
treat	O
the	O
element	O
as	O
a	O
reference	O
and	O
follow	O
it	O
,	O
or	O
whether	O
it	O
is	O
a	O
primitive	O
value	O
.	O
</s>
<s>
The	O
garbage	B-General_Concept
collector	I-General_Concept
can	O
reclaim	O
only	O
objects	O
that	O
have	O
no	O
references	O
pointing	O
to	O
them	O
either	O
directly	O
or	O
indirectly	O
from	O
the	O
root	B-General_Concept
set	I-General_Concept
.	O
</s>
<s>
However	O
,	O
some	O
programs	O
require	O
weak	B-General_Concept
references	I-General_Concept
,	O
which	O
should	O
be	O
usable	O
for	O
as	O
long	O
as	O
the	O
object	O
exists	O
but	O
should	O
not	O
prolong	O
its	O
lifetime	O
.	O
</s>
<s>
In	O
discussions	O
about	O
weak	B-General_Concept
references	I-General_Concept
,	O
ordinary	O
references	O
are	O
sometimes	O
called	O
strong	B-General_Concept
references	I-General_Concept
.	O
</s>
<s>
An	O
object	O
is	O
eligible	O
for	O
garbage	B-General_Concept
collection	I-General_Concept
if	O
there	O
are	O
no	O
strong	O
(	O
i.e.	O
</s>
<s>
ordinary	O
)	O
references	O
to	O
it	O
,	O
even	O
though	O
there	O
still	O
might	O
be	O
some	O
weak	B-General_Concept
references	I-General_Concept
to	O
it	O
.	O
</s>
<s>
A	O
weak	B-General_Concept
reference	I-General_Concept
is	O
not	O
merely	O
just	O
any	O
pointer	O
to	O
the	O
object	O
that	O
a	O
garbage	B-General_Concept
collector	I-General_Concept
does	O
not	O
care	O
about	O
.	O
</s>
<s>
An	O
unsafe	O
reference	O
that	O
is	O
not	O
known	O
to	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
will	O
simply	O
remain	O
dangling	O
by	O
continuing	O
to	O
refer	O
to	O
the	O
address	O
where	O
the	O
object	O
previously	O
resided	O
.	O
</s>
<s>
This	O
is	O
not	O
a	O
weak	B-General_Concept
reference	I-General_Concept
.	O
</s>
<s>
In	O
some	O
implementations	O
,	O
weak	B-General_Concept
references	I-General_Concept
are	O
divided	O
into	O
subcategories	O
.	O
</s>
<s>
For	O
example	O
,	O
the	O
Java	B-Language
Virtual	I-Language
Machine	I-Language
provides	O
three	O
forms	O
of	O
weak	B-General_Concept
references	I-General_Concept
,	O
namely	O
soft	B-General_Concept
references	I-General_Concept
,	O
phantom	B-General_Concept
references	I-General_Concept
,	O
and	O
regular	O
weak	B-General_Concept
references	I-General_Concept
.	O
</s>
<s>
A	O
softly	O
referenced	O
object	O
is	O
only	O
eligible	O
for	O
reclamation	O
,	O
if	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
decides	O
that	O
the	O
program	O
is	O
low	O
on	O
memory	O
.	O
</s>
<s>
Unlike	O
a	O
soft	B-General_Concept
reference	I-General_Concept
or	O
a	O
regular	O
weak	B-General_Concept
reference	I-General_Concept
,	O
a	O
phantom	B-General_Concept
reference	I-General_Concept
does	O
not	O
provide	O
access	O
to	O
the	O
object	O
that	O
it	O
references	O
.	O
</s>
<s>
Instead	O
,	O
a	O
phantom	B-General_Concept
reference	I-General_Concept
is	O
a	O
mechanism	O
that	O
allows	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
to	O
notify	O
the	O
program	O
when	O
the	O
referenced	O
object	O
has	O
become	O
phantom	B-General_Concept
reachable	I-General_Concept
.	O
</s>
<s>
An	O
object	O
is	O
phantom	B-General_Concept
reachable	I-General_Concept
,	O
if	O
it	O
still	O
resides	O
in	O
memory	O
and	O
it	O
is	O
referenced	O
by	O
a	O
phantom	B-General_Concept
reference	I-General_Concept
,	O
but	O
its	O
finalizer	B-Application
has	O
already	O
executed	O
.	O
</s>
<s>
Similarly	O
,	O
Microsoft.NET	B-Application
provides	O
two	O
subcategories	O
of	O
weak	B-General_Concept
references	I-General_Concept
,	O
namely	O
long	O
weak	B-General_Concept
references	I-General_Concept
(	O
tracks	O
resurrection	O
)	O
and	O
short	O
weak	B-General_Concept
references	I-General_Concept
.	O
</s>
<s>
Data	B-General_Concept
structures	I-General_Concept
can	O
also	O
be	O
devised	O
which	O
have	O
weak	O
tracking	O
features	O
.	O
</s>
<s>
For	O
instance	O
,	O
weak	O
hash	B-Algorithm
tables	I-Algorithm
are	O
useful	O
.	O
</s>
<s>
Like	O
a	O
regular	O
hash	B-Algorithm
table	I-Algorithm
,	O
a	O
weak	O
hash	B-Algorithm
table	I-Algorithm
maintains	O
an	O
association	O
between	O
pairs	O
of	O
objects	O
,	O
where	O
each	O
pair	O
is	O
understood	O
to	O
be	O
a	O
key	O
and	O
value	O
.	O
</s>
<s>
However	O
,	O
the	O
hash	B-Algorithm
table	I-Algorithm
does	O
not	O
actually	O
maintain	O
a	O
strong	B-General_Concept
reference	I-General_Concept
on	O
these	O
objects	O
.	O
</s>
<s>
Special	O
behavior	O
takes	O
place	O
when	O
either	O
the	O
key	O
or	O
value	O
or	O
both	O
become	O
garbage	O
:	O
the	O
hash	B-Algorithm
table	I-Algorithm
entry	O
is	O
spontaneously	O
deleted	O
.	O
</s>
<s>
There	O
exist	O
further	O
refinements	O
such	O
as	O
hash	B-Algorithm
tables	I-Algorithm
which	O
have	O
only	O
weak	O
keys	O
(	O
value	O
references	O
are	O
ordinary	O
,	O
strong	B-General_Concept
references	I-General_Concept
)	O
or	O
only	O
weak	O
values	O
(	O
key	O
references	O
are	O
strong	O
)	O
.	O
</s>
<s>
Weak	O
hash	B-Algorithm
tables	I-Algorithm
are	O
important	O
for	O
maintaining	O
associations	O
between	O
objects	O
,	O
such	O
that	O
the	O
objects	O
engaged	O
in	O
the	O
association	O
can	O
still	O
become	O
garbage	O
if	O
nothing	O
in	O
the	O
program	O
refers	O
to	O
them	O
any	O
longer	O
(	O
other	O
than	O
the	O
associating	O
hash	B-Algorithm
table	I-Algorithm
)	O
.	O
</s>
<s>
The	O
use	O
of	O
a	O
regular	O
hash	B-Algorithm
table	I-Algorithm
for	O
such	O
a	O
purpose	O
could	O
lead	O
to	O
a	O
"	O
logical	O
memory	O
leak	O
"	O
:	O
the	O
accumulation	O
of	O
reachable	O
data	O
which	O
the	O
program	O
does	O
not	O
need	O
and	O
will	O
not	O
use	O
.	O
</s>
<s>
These	O
garbage	B-General_Concept
collectors	I-General_Concept
perform	O
collection	O
in	O
cycles	O
.	O
</s>
<s>
In	O
the	O
naive	O
mark-and-sweep	O
method	O
,	O
each	O
object	O
in	O
memory	O
has	O
a	O
flag	O
(	O
typically	O
a	O
single	O
bit	O
)	O
reserved	O
for	O
garbage	B-General_Concept
collection	I-General_Concept
use	O
only	O
.	O
</s>
<s>
The	O
first	O
stage	O
is	O
the	O
mark	O
stage	O
which	O
does	O
a	O
tree	O
traversal	O
of	O
the	O
entire	O
'	O
root	B-General_Concept
set	I-General_Concept
 '	O
and	O
marks	O
each	O
object	O
that	O
is	O
pointed	O
to	O
by	O
a	O
root	O
as	O
being	O
'	O
in-use	O
'	O
.	O
</s>
<s>
All	O
objects	O
that	O
those	O
objects	O
point	O
to	O
,	O
and	O
so	O
on	O
,	O
are	O
marked	O
as	O
well	O
,	O
so	O
that	O
every	O
object	O
that	O
is	O
reachable	O
via	O
the	O
root	B-General_Concept
set	I-General_Concept
is	O
marked	O
.	O
</s>
<s>
This	O
can	O
cause	O
programs	O
to	O
'	O
freeze	O
 '	O
periodically	O
(	O
and	O
generally	O
unpredictably	O
)	O
,	O
making	O
some	O
real-time	B-General_Concept
and	O
time-critical	O
applications	O
impossible	O
.	O
</s>
<s>
In	O
addition	O
,	O
the	O
entire	O
working	O
memory	O
must	O
be	O
examined	O
,	O
much	O
of	O
it	O
twice	O
,	O
potentially	O
causing	O
problems	O
in	O
paged	B-Architecture
memory	I-Architecture
systems	O
.	O
</s>
<s>
Because	O
of	O
these	O
performance	O
problems	O
,	O
most	O
modern	O
tracing	B-General_Concept
garbage	I-General_Concept
collectors	I-General_Concept
implement	O
some	O
variant	O
of	O
the	O
tri-color	O
marking	O
abstraction	B-Application
,	O
but	O
simple	O
collectors	O
(	O
such	O
as	O
the	O
mark-and-sweep	O
collector	O
)	O
often	O
do	O
not	O
make	O
this	O
abstraction	B-Application
explicit	O
.	O
</s>
<s>
By	O
monitoring	O
the	O
size	O
of	O
the	O
sets	O
,	O
the	O
system	O
can	O
perform	O
garbage	B-General_Concept
collection	I-General_Concept
periodically	O
,	O
rather	O
than	O
as	O
needed	O
.	O
</s>
<s>
Once	O
the	O
unreachable	B-General_Concept
set	O
has	O
been	O
determined	O
,	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
may	O
simply	O
release	O
the	O
unreachable	B-General_Concept
objects	I-General_Concept
and	O
leave	O
everything	O
else	O
as	O
it	O
is	O
,	O
or	O
it	O
may	O
copy	O
some	O
or	O
all	O
of	O
the	O
reachable	O
objects	O
into	O
a	O
new	O
area	O
of	O
memory	O
,	O
updating	O
all	O
references	O
to	O
those	O
objects	O
as	O
needed	O
.	O
</s>
<s>
These	O
are	O
called	O
"	O
non-moving	O
"	O
and	O
"	O
moving	O
"	O
(	O
or	O
,	O
alternatively	O
,	O
"	O
non-compacting	O
"	O
and	O
"	O
compacting	O
"	O
)	O
garbage	B-General_Concept
collectors	I-General_Concept
,	O
respectively	O
.	O
</s>
<s>
But	O
the	O
moving	O
algorithm	O
leads	O
to	O
several	O
performance	O
advantages	O
,	O
both	O
during	O
the	O
garbage	B-General_Concept
collection	I-General_Concept
cycle	O
itself	O
and	O
during	O
program	O
execution	O
:	O
</s>
<s>
In	O
contrast	O
,	O
a	O
non-moving	O
GC	O
must	O
visit	O
each	O
unreachable	B-General_Concept
object	I-General_Concept
and	O
record	O
that	O
the	O
memory	O
it	O
occupied	O
is	O
available	O
.	O
</s>
<s>
A	O
non-moving	O
strategy	O
may	O
,	O
after	O
some	O
time	O
,	O
lead	O
to	O
a	O
heavily	O
fragmented	B-Architecture
heap	O
,	O
requiring	O
expensive	O
consultation	O
of	O
"	O
free	O
lists	O
"	O
of	O
small	O
available	O
blocks	O
of	O
memory	O
in	O
order	O
to	O
allocate	O
new	O
objects	O
.	O
</s>
<s>
If	O
an	O
appropriate	O
traversal	O
order	O
is	O
used	O
(	O
such	O
as	O
cdr-first	O
for	O
list	O
conses	O
)	O
,	O
objects	O
can	O
be	O
moved	O
very	O
close	O
to	O
the	O
objects	O
they	O
refer	O
to	O
in	O
memory	O
,	O
increasing	O
the	O
chance	O
that	O
they	O
will	O
be	O
located	O
in	O
the	O
same	O
cache	B-General_Concept
line	I-General_Concept
or	O
virtual	B-Architecture
memory	I-Architecture
page	O
.	O
</s>
<s>
One	O
disadvantage	O
of	O
a	O
moving	O
garbage	B-General_Concept
collector	I-General_Concept
is	O
that	O
it	O
only	O
allows	O
access	O
through	O
references	O
that	O
are	O
managed	O
by	O
the	O
garbage	B-General_Concept
collected	I-General_Concept
environment	O
,	O
and	O
does	O
not	O
allow	O
pointer	O
arithmetic	O
.	O
</s>
<s>
This	O
is	O
because	O
any	O
pointers	O
to	O
objects	O
will	O
be	O
invalidated	O
if	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
moves	O
those	O
objects	O
(	O
they	O
become	O
dangling	B-Error_Name
pointers	I-Error_Name
)	O
.	O
</s>
<s>
For	O
interoperability	O
with	O
native	O
code	O
,	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
must	O
copy	O
the	O
object	O
contents	O
to	O
a	O
location	O
outside	O
of	O
the	O
garbage	B-General_Concept
collected	I-General_Concept
region	O
of	O
memory	O
.	O
</s>
<s>
An	O
alternative	O
approach	O
is	O
to	O
pin	O
the	O
object	O
in	O
memory	O
,	O
preventing	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
from	O
moving	O
it	O
and	O
allowing	O
the	O
memory	O
to	O
be	O
directly	O
shared	O
with	O
native	O
pointers	O
(	O
and	O
possibly	O
allowing	O
pointer	O
arithmetic	O
)	O
.	O
</s>
<s>
The	O
objects	O
reachable	O
from	O
the	O
root	B-General_Concept
set	I-General_Concept
are	O
copied	O
from	O
the	O
"	O
from	O
space	O
"	O
to	O
the	O
"	O
to	O
space	O
"	O
.	O
</s>
<s>
Cheney	B-General_Concept
's	I-General_Concept
algorithm	I-General_Concept
is	O
an	O
improvement	O
on	O
the	O
semi-space	O
collector	O
.	O
</s>
<s>
A	O
mark	O
and	O
sweep	O
garbage	B-General_Concept
collector	I-General_Concept
keeps	O
a	O
bit	O
or	O
two	O
with	O
each	O
object	O
to	O
record	O
if	O
it	O
is	O
white	O
or	O
black	O
.	O
</s>
<s>
This	O
can	O
be	O
somewhat	O
mitigated	O
if	O
the	O
collector	O
also	O
handles	O
allocation	O
,	O
since	O
then	O
it	O
could	O
potentially	O
use	O
unused	O
bits	O
in	O
the	O
allocation	O
data	B-General_Concept
structures	I-General_Concept
.	O
</s>
<s>
A	O
mark	O
and	O
do	O
n't	O
sweep	O
garbage	B-General_Concept
collector	I-General_Concept
,	O
like	O
the	O
mark-and-sweep	O
,	O
keeps	O
a	O
bit	O
with	O
each	O
object	O
to	O
record	O
if	O
it	O
is	O
white	O
or	O
black	O
;	O
the	O
grey	O
set	O
is	O
kept	O
as	O
a	O
separate	O
list	O
or	O
using	O
another	O
bit	O
.	O
</s>
<s>
An	O
object	O
is	O
marked	O
black	O
at	O
the	O
time	O
it	O
is	O
allocated	O
,	O
and	O
it	O
will	O
stay	O
black	O
even	O
if	O
it	O
becomes	O
unreachable	B-General_Concept
.	O
</s>
<s>
Once	O
this	O
is	O
done	O
,	O
all	O
unreachable	B-General_Concept
memory	I-General_Concept
is	O
white	O
.	O
</s>
<s>
It	O
has	O
been	O
empirically	O
observed	O
that	O
in	O
many	O
programs	O
,	O
the	O
most	O
recently	O
created	O
objects	O
are	O
also	O
those	O
most	O
likely	O
to	O
become	O
unreachable	B-General_Concept
quickly	O
(	O
known	O
as	O
infant	O
mortality	O
or	O
the	O
generational	O
hypothesis	O
)	O
.	O
</s>
<s>
A	O
generational	B-General_Concept
GC	I-General_Concept
(	O
also	O
known	O
as	O
ephemeral	O
GC	O
)	O
divides	O
objects	O
into	O
generations	O
and	O
,	O
on	O
most	O
cycles	O
,	O
will	O
place	O
only	O
the	O
objects	O
of	O
a	O
subset	O
of	O
generations	O
into	O
the	O
initial	O
white	O
(	O
condemned	O
)	O
set	O
.	O
</s>
<s>
When	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
runs	O
,	O
it	O
may	O
be	O
able	O
to	O
use	O
this	O
knowledge	O
to	O
prove	O
that	O
some	O
objects	O
in	O
the	O
initial	O
white	O
set	O
are	O
unreachable	B-General_Concept
without	O
having	O
to	O
traverse	O
the	O
entire	O
reference	O
tree	O
.	O
</s>
<s>
If	O
the	O
generational	O
hypothesis	O
holds	O
,	O
this	O
results	O
in	O
much	O
faster	O
collection	O
cycles	O
while	O
still	O
reclaiming	O
most	O
unreachable	B-General_Concept
objects	I-General_Concept
.	O
</s>
<s>
In	O
order	O
to	O
implement	O
this	O
concept	O
,	O
many	O
generational	O
garbage	B-General_Concept
collectors	I-General_Concept
use	O
separate	O
memory	O
regions	O
for	O
different	O
ages	O
of	O
objects	O
.	O
</s>
<s>
This	O
technique	O
permits	O
very	O
fast	O
incremental	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
since	O
the	O
garbage	B-General_Concept
collection	I-General_Concept
of	O
only	O
one	O
region	O
at	O
a	O
time	O
is	O
all	O
that	O
is	O
typically	O
required	O
.	O
</s>
<s>
Generational	O
garbage	B-General_Concept
collection	I-General_Concept
is	O
a	O
heuristic	B-Algorithm
approach	O
,	O
and	O
some	O
unreachable	B-General_Concept
objects	I-General_Concept
may	O
not	O
be	O
reclaimed	O
on	O
each	O
cycle	O
.	O
</s>
<s>
It	O
may	O
therefore	O
occasionally	O
be	O
necessary	O
to	O
perform	O
a	O
full	O
mark	O
and	O
sweep	O
or	O
copying	O
garbage	B-General_Concept
collection	I-General_Concept
to	O
reclaim	O
all	O
available	O
space	O
.	O
</s>
<s>
In	O
fact	O
,	O
runtime	O
systems	O
for	O
modern	O
programming	O
languages	O
(	O
such	O
as	O
Java	B-Language
and	O
the	O
.NET	B-Application
Framework	I-Application
)	O
usually	O
use	O
some	O
hybrid	O
of	O
the	O
various	O
strategies	O
that	O
have	O
been	O
described	O
thus	O
far	O
;	O
for	O
example	O
,	O
most	O
collection	O
cycles	O
might	O
look	O
only	O
at	O
a	O
few	O
generations	O
,	O
while	O
occasionally	O
a	O
mark-and-sweep	O
is	O
performed	O
,	O
and	O
even	O
more	O
rarely	O
a	O
full	O
copying	O
is	O
performed	O
to	O
combat	O
fragmentation	B-Architecture
.	O
</s>
<s>
Simple	O
stop-the-world	O
garbage	B-General_Concept
collectors	I-General_Concept
completely	O
halt	O
execution	O
of	O
the	O
program	O
to	O
run	O
a	O
collection	O
cycle	O
,	O
thus	O
guaranteeing	O
that	O
new	O
objects	O
are	O
not	O
allocated	O
and	O
objects	O
do	O
not	O
suddenly	O
become	O
unreachable	B-General_Concept
while	O
the	O
collector	O
is	O
running	O
.	O
</s>
<s>
Stop-the-world	O
garbage	B-General_Concept
collection	I-General_Concept
is	O
therefore	O
mainly	O
suitable	O
for	O
non-interactive	O
programs	O
.	O
</s>
<s>
Its	O
advantage	O
is	O
that	O
it	O
is	O
both	O
simpler	O
to	O
implement	O
and	O
faster	O
than	O
incremental	O
garbage	B-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
Incremental	O
and	O
concurrent	O
garbage	B-General_Concept
collectors	I-General_Concept
are	O
designed	O
to	O
reduce	O
this	O
disruption	O
by	O
interleaving	O
their	O
work	O
with	O
activity	O
from	O
the	O
main	O
program	O
.	O
</s>
<s>
Incremental	O
garbage	B-General_Concept
collectors	I-General_Concept
perform	O
the	O
garbage	B-General_Concept
collection	I-General_Concept
cycle	O
in	O
discrete	O
phases	O
,	O
with	O
program	O
execution	O
permitted	O
between	O
each	O
phase	O
(	O
and	O
sometimes	O
during	O
some	O
phases	O
)	O
.	O
</s>
<s>
Concurrent	O
garbage	B-General_Concept
collectors	I-General_Concept
do	O
not	O
stop	O
program	O
execution	O
at	O
all	O
,	O
except	O
perhaps	O
briefly	O
when	O
the	O
program	O
's	O
execution	O
stack	O
is	O
scanned	O
.	O
</s>
<s>
However	O
,	O
the	O
sum	O
of	O
the	O
incremental	O
phases	O
takes	O
longer	O
to	O
complete	O
than	O
one	O
batch	O
garbage	B-General_Concept
collection	I-General_Concept
pass	O
,	O
so	O
these	O
garbage	B-General_Concept
collectors	I-General_Concept
may	O
yield	O
lower	O
total	O
throughput	O
.	O
</s>
<s>
Careful	O
design	O
is	O
necessary	O
with	O
these	O
techniques	O
to	O
ensure	O
that	O
the	O
main	O
program	O
does	O
not	O
interfere	O
with	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
and	O
vice	O
versa	O
;	O
for	O
example	O
,	O
when	O
the	O
program	O
needs	O
to	O
allocate	O
a	O
new	O
object	O
,	O
the	O
runtime	O
system	O
may	O
either	O
need	O
to	O
suspend	O
it	O
until	O
the	O
collection	O
cycle	O
is	O
complete	O
,	O
or	O
somehow	O
notify	O
the	O
garbage	B-General_Concept
collector	I-General_Concept
that	O
there	O
exists	O
a	O
new	O
,	O
reachable	O
object	O
.	O
</s>
<s>
False	O
positives	O
are	O
generally	O
less	O
problematic	O
on	O
64-bit	B-Device
systems	O
than	O
on	O
32-bit	O
systems	O
because	O
the	O
range	O
of	O
valid	O
memory	O
addresses	O
tends	O
to	O
be	O
a	O
tiny	O
fraction	O
of	O
the	O
range	O
of	O
64-bit	B-Device
values	O
.	O
</s>
<s>
Thus	O
,	O
an	O
arbitrary	O
64-bit	B-Device
pattern	O
is	O
unlikely	O
to	O
mimic	O
a	O
valid	O
pointer	O
.	O
</s>
<s>
A	O
false	O
negative	O
can	O
also	O
happen	O
if	O
pointers	O
are	O
"	O
hidden	O
"	O
,	O
for	O
example	O
using	O
an	O
XOR	B-Data_Structure
linked	I-Data_Structure
list	I-Data_Structure
.	O
</s>
<s>
An	O
example	O
for	O
which	O
a	O
conservative	B-General_Concept
garbage	I-General_Concept
collector	I-General_Concept
would	O
be	O
needed	O
is	O
the	O
C	B-Language
language	I-Language
,	O
which	O
allows	O
typed	O
(	O
non-void	O
)	O
pointers	O
to	O
be	O
type	O
cast	O
into	O
untyped	O
(	O
void	O
)	O
pointers	O
,	O
and	O
vice	O
versa	O
.	O
</s>
<s>
An	O
example	O
for	O
this	O
is	O
the	O
C++	B-Language
language	I-Language
,	O
in	O
which	O
multiple	O
inheritance	O
can	O
cause	O
pointers	O
to	O
base	O
objects	O
to	O
have	O
different	O
addresses	O
.	O
</s>
<s>
Performance	O
of	O
tracing	B-General_Concept
garbage	I-General_Concept
collectors	I-General_Concept
–	O
both	O
latency	O
and	O
throughput	O
–	O
depends	O
significantly	O
on	O
the	O
implementation	O
,	O
workload	O
,	O
and	O
environment	O
.	O
</s>
<s>
Naive	O
implementations	O
or	O
use	O
in	O
very	O
memory-constrained	O
environments	O
,	O
notably	O
embedded	B-Architecture
systems	I-Architecture
,	O
can	O
result	O
in	O
very	O
poor	O
performance	O
compared	O
with	O
other	O
methods	O
,	O
while	O
sophisticated	O
implementations	O
and	O
use	O
in	O
environments	O
with	O
ample	O
memory	O
can	O
result	O
in	O
excellent	O
performance	O
.	O
</s>
<s>
Manual	O
memory	O
management	O
requires	O
overhead	O
due	O
to	O
explicit	O
freeing	O
of	O
memory	O
,	O
and	O
reference	B-General_Concept
counting	I-General_Concept
has	O
overhead	O
from	O
incrementing	O
and	O
decrementing	O
reference	B-General_Concept
counts	I-General_Concept
,	O
and	O
checking	O
if	O
the	O
count	O
has	O
overflowed	O
or	O
dropped	O
to	O
zero	O
.	O
</s>
<s>
In	O
terms	O
of	O
latency	O
,	O
simple	O
stop-the-world	O
garbage	B-General_Concept
collectors	I-General_Concept
pause	O
program	O
execution	O
for	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
which	O
can	O
happen	O
at	O
arbitrary	O
times	O
and	O
take	O
arbitrarily	O
long	O
,	O
making	O
them	O
unusable	O
for	O
real-time	B-General_Concept
computing	I-General_Concept
,	O
notably	O
embedded	B-Architecture
systems	I-Architecture
,	O
and	O
a	O
poor	O
fit	O
for	O
interactive	O
use	O
,	O
or	O
any	O
other	O
situation	O
where	O
low	O
latency	O
is	O
a	O
priority	O
.	O
</s>
<s>
However	O
,	O
incremental	O
garbage	B-General_Concept
collectors	I-General_Concept
can	O
provide	O
hard	O
real-time	B-General_Concept
guarantees	O
,	O
and	O
on	O
systems	O
with	O
frequent	O
idle	O
time	O
and	O
sufficient	O
free	O
memory	O
,	O
such	O
as	O
personal	O
computers	O
,	O
garbage	B-General_Concept
collection	I-General_Concept
can	O
be	O
scheduled	O
for	O
idle	O
times	O
and	O
have	O
minimal	O
impact	O
on	O
interactive	O
performance	O
.	O
</s>
<s>
Manual	O
memory	O
management	O
(	O
as	O
in	O
C++	B-Language
)	O
and	O
reference	B-General_Concept
counting	I-General_Concept
have	O
a	O
similar	O
issue	O
of	O
arbitrarily	O
long	O
pauses	O
in	O
case	O
of	O
deallocating	O
a	O
large	O
data	B-General_Concept
structure	I-General_Concept
and	O
all	O
its	O
children	O
,	O
though	O
these	O
only	O
occur	O
at	O
fixed	O
times	O
,	O
not	O
depending	O
on	O
garbage	B-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
However	O
,	O
this	O
size	O
segregation	O
usually	O
cause	O
a	O
large	O
degree	O
of	O
external	O
fragmentation	B-Architecture
,	O
which	O
can	O
have	O
an	O
adverse	O
impact	O
on	O
cache	O
behaviour	O
.	O
</s>
<s>
Memory	O
allocation	O
in	O
a	O
garbage	B-General_Concept
collected	I-General_Concept
language	O
may	O
be	O
implemented	O
using	O
heap	O
allocation	O
behind	O
the	O
scenes	O
(	O
rather	O
than	O
simply	O
incrementing	O
a	O
pointer	O
)	O
,	O
so	O
the	O
performance	O
advantages	O
listed	O
above	O
do	O
n't	O
necessarily	O
apply	O
in	O
this	O
case	O
.	O
</s>
<s>
In	O
some	O
situations	O
,	O
most	O
notably	O
embedded	B-Architecture
systems	I-Architecture
,	O
it	O
is	O
possible	O
to	O
avoid	O
both	O
garbage	B-General_Concept
collection	I-General_Concept
and	O
heap	O
management	O
overhead	O
by	O
preallocating	O
pools	O
of	O
memory	O
and	O
using	O
a	O
custom	O
,	O
lightweight	O
scheme	O
for	O
allocation/deallocation	O
.	O
</s>
<s>
The	O
overhead	O
of	O
write	O
barriers	O
is	O
more	O
likely	O
to	O
be	O
noticeable	O
in	O
an	O
imperative-style	O
program	O
which	O
frequently	O
writes	O
pointers	O
into	O
existing	O
data	B-General_Concept
structures	I-General_Concept
than	O
in	O
a	O
functional-style	O
program	O
which	O
constructs	O
data	O
only	O
once	O
and	O
never	O
changes	O
them	O
.	O
</s>
<s>
Some	O
advances	O
in	O
garbage	B-General_Concept
collection	I-General_Concept
can	O
be	O
understood	O
as	O
reactions	O
to	O
performance	O
issues	O
.	O
</s>
<s>
Tracing	B-General_Concept
garbage	I-General_Concept
collection	I-General_Concept
is	O
not	O
deterministic	B-General_Concept
in	O
the	O
timing	O
of	O
object	O
finalization	O
.	O
</s>
<s>
An	O
object	O
which	O
becomes	O
eligible	O
for	O
garbage	B-General_Concept
collection	I-General_Concept
will	O
usually	O
be	O
cleaned	O
up	O
eventually	O
,	O
but	O
there	O
is	O
no	O
guarantee	O
when	O
(	O
or	O
even	O
if	O
)	O
that	O
will	O
happen	O
.	O
</s>
<s>
One	O
garbage	B-General_Concept
collection	I-General_Concept
technique	O
which	O
provides	O
determinism	O
in	O
this	O
regard	O
is	O
reference	B-General_Concept
counting	I-General_Concept
.	O
</s>
<s>
Garbage	B-General_Concept
collection	I-General_Concept
can	O
have	O
a	O
nondeterministic	O
impact	O
on	O
execution	O
time	O
,	O
by	O
potentially	O
introducing	O
pauses	O
into	O
the	O
execution	O
of	O
a	O
program	O
which	O
are	O
not	O
correlated	O
with	O
the	O
algorithm	O
being	O
processed	O
.	O
</s>
<s>
Under	O
tracing	B-General_Concept
garbage	I-General_Concept
collection	I-General_Concept
,	O
the	O
request	O
to	O
allocate	O
a	O
new	O
object	O
can	O
sometimes	O
return	O
quickly	O
and	O
at	O
other	O
times	O
trigger	O
a	O
lengthy	O
garbage	B-General_Concept
collection	I-General_Concept
cycle	O
.	O
</s>
<s>
Under	O
reference	B-General_Concept
counting	I-General_Concept
,	O
whereas	O
allocation	O
of	O
objects	O
is	O
usually	O
fast	O
,	O
decrementing	O
a	O
reference	O
is	O
nondeterministic	O
,	O
since	O
a	O
reference	O
may	O
reach	O
zero	O
,	O
triggering	O
recursion	O
to	O
decrement	O
the	O
reference	B-General_Concept
counts	I-General_Concept
of	O
other	O
objects	O
which	O
that	O
object	O
holds	O
.	O
</s>
<s>
While	O
garbage	B-General_Concept
collection	I-General_Concept
is	O
generally	O
nondeterministic	O
,	O
it	O
is	O
possible	O
to	O
use	O
it	O
in	O
hard	O
real-time	B-General_Concept
systems	I-General_Concept
.	O
</s>
<s>
A	O
real-time	B-General_Concept
garbage	B-General_Concept
collector	I-General_Concept
should	O
guarantee	O
that	O
even	O
in	O
the	O
worst	O
case	O
it	O
will	O
dedicate	O
a	O
certain	O
number	O
of	O
computational	O
resources	O
to	O
mutator	O
threads	O
.	O
</s>
<s>
Constraints	O
imposed	O
on	O
a	O
real-time	B-General_Concept
garbage	B-General_Concept
collector	I-General_Concept
are	O
usually	O
either	O
work	O
based	O
or	O
time	O
based	O
.	O
</s>
<s>
For	O
work	O
based	O
analysis	O
,	O
MMU	O
(	O
minimal	O
mutator	O
utilization	O
)	O
is	O
usually	O
used	O
as	O
a	O
real-time	B-General_Concept
constraint	O
for	O
the	O
garbage	B-General_Concept
collection	I-General_Concept
algorithm	O
.	O
</s>
<s>
One	O
of	O
the	O
first	O
implementations	O
of	O
hard	O
real-time	B-General_Concept
garbage	B-General_Concept
collection	I-General_Concept
for	O
the	O
JVM	B-Language
was	O
based	O
on	O
the	O
Metronome	O
algorithm	O
,	O
whose	O
commercial	O
implementation	O
is	O
available	O
as	O
part	O
of	O
the	O
IBM	B-Language
WebSphere	I-Language
Real	I-Language
Time	I-Language
.	O
</s>
<s>
Another	O
hard	O
real-time	B-General_Concept
garbage	B-General_Concept
collection	I-General_Concept
algorithm	O
is	O
Staccato	O
,	O
available	O
in	O
the	O
IBM	O
's	O
J9	B-Language
JVM	I-Language
,	O
which	O
also	O
provides	O
scalability	O
to	O
large	O
multiprocessor	O
architectures	O
,	O
while	O
bringing	O
various	O
advantages	O
over	O
Metronome	O
and	O
other	O
algorithms	O
which	O
,	O
on	O
the	O
contrary	O
,	O
require	O
specialized	O
hardware	O
.	O
</s>
<s>
One	O
major	O
challenge	O
for	O
real-time	B-General_Concept
garbage	B-General_Concept
collection	I-General_Concept
on	O
modern	O
multi-core	O
architectures	O
is	O
in	O
designing	O
a	O
non-blocking	O
concurrent	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
not	O
letting	O
the	O
concurrent	O
threads	O
block	O
each	O
other	O
and	O
create	O
unpredictable	O
pauses	O
.	O
</s>
<s>
A	O
study	O
of	O
algorithms	O
that	O
allow	O
non-blocking	O
real-time	B-General_Concept
concurrent	O
garbage	B-General_Concept
collection	I-General_Concept
appears	O
in	O
a	O
paper	O
by	O
Pizlo	O
et	O
al	O
.	O
</s>
