<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
garbage	B-General_Concept
collection	I-General_Concept
(	O
GC	O
)	O
is	O
a	O
form	O
of	O
automatic	B-General_Concept
memory	I-General_Concept
management	I-General_Concept
.	O
</s>
<s>
The	O
garbage	B-General_Concept
collector	I-General_Concept
attempts	O
to	O
reclaim	O
memory	O
which	O
was	O
allocated	O
by	O
the	O
program	O
,	O
but	O
is	O
no	O
longer	O
referenced	O
;	O
such	O
memory	O
is	O
called	O
garbage	B-General_Concept
.	O
</s>
<s>
Garbage	B-General_Concept
collection	I-General_Concept
was	O
invented	O
by	O
American	O
computer	O
scientist	O
John	O
McCarthy	O
around	O
1959	O
to	O
simplify	O
manual	B-Application
memory	I-Application
management	I-Application
in	O
Lisp	B-Language
.	O
</s>
<s>
Garbage	B-General_Concept
collection	I-General_Concept
relieves	O
the	O
programmer	O
from	O
doing	O
manual	B-Application
memory	I-Application
management	I-Application
,	O
where	O
the	O
programmer	O
specifies	O
what	O
objects	O
to	O
de-allocate	O
and	O
return	O
to	O
the	O
memory	O
system	O
and	O
when	O
to	O
do	O
so	O
.	O
</s>
<s>
Other	O
,	O
similar	O
techniques	O
include	O
stack	B-General_Concept
allocation	I-General_Concept
,	O
region	B-General_Concept
inference	I-General_Concept
,	O
and	O
memory	O
ownership	O
,	O
and	O
combinations	O
thereof	O
.	O
</s>
<s>
Garbage	B-General_Concept
collection	I-General_Concept
may	O
take	O
a	O
significant	O
proportion	O
of	O
a	O
program	O
's	O
total	O
processing	O
time	O
,	O
and	O
affect	O
performance	O
as	O
a	O
result	O
.	O
</s>
<s>
Resources	O
other	O
than	O
memory	O
,	O
such	O
as	O
network	B-Protocol
sockets	I-Protocol
,	O
database	O
handles	O
,	O
windows	O
,	O
file	B-Operating_System
descriptors	O
,	O
and	O
device	O
descriptors	O
,	O
are	O
not	O
typically	O
handled	O
by	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
but	O
rather	O
by	O
other	O
methods	O
(	O
e.g.	O
</s>
<s>
destructors	B-Language
)	O
.	O
</s>
<s>
Many	O
programming	O
languages	O
require	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
either	O
as	O
part	O
of	O
the	O
language	O
specification	O
(	O
e.g.	O
,	O
RPL	B-Device
,	O
Java	B-Language
,	O
C#	B-Application
,	O
D	B-Application
,	O
Go	B-Application
,	O
and	O
most	O
scripting	B-Language
languages	I-Language
)	O
or	O
effectively	O
for	O
practical	O
implementation	O
(	O
e.g.	O
,	O
formal	O
languages	O
like	O
lambda	B-Language
calculus	I-Language
)	O
.	O
</s>
<s>
These	O
are	O
said	O
to	O
be	O
garbage-collected	O
languages	O
.	O
</s>
<s>
Other	O
languages	O
,	O
such	O
as	O
C	B-Language
and	O
C++	B-Language
,	O
were	O
designed	O
for	O
use	O
with	O
manual	B-Application
memory	I-Application
management	I-Application
,	O
but	O
have	O
garbage-collected	O
implementations	O
available	O
.	O
</s>
<s>
Some	O
languages	O
,	O
like	O
Ada	B-Language
,	O
Modula-3	B-Language
,	O
and	O
C++	B-Language
/CLI	I-Language
,	O
allow	O
both	O
garbage	B-General_Concept
collection	I-General_Concept
and	O
manual	B-Application
memory	I-Application
management	I-Application
to	O
co-exist	O
in	O
the	O
same	O
application	O
by	O
using	O
separate	O
heaps	B-Application
for	O
collected	O
and	O
manually	O
managed	O
objects	O
.	O
</s>
<s>
Still	O
others	O
,	O
like	O
D	B-Application
,	O
are	O
garbage-collected	O
but	O
allow	O
the	O
user	O
to	O
manually	O
delete	O
objects	O
or	O
even	O
disable	O
garbage	B-General_Concept
collection	I-General_Concept
entirely	O
when	O
speed	O
is	O
required	O
.	O
</s>
<s>
Although	O
many	O
languages	O
integrate	O
GC	O
into	O
their	O
compiler	B-Language
and	O
runtime	B-Device
system	I-Device
,	O
post-hoc	O
GC	O
systems	O
also	O
exist	O
,	O
such	O
as	O
Automatic	B-Language
Reference	I-Language
Counting	I-Language
(	O
ARC	O
)	O
.	O
</s>
<s>
Dangling	B-Error_Name
pointers	I-Error_Name
,	O
which	O
occur	O
when	O
a	O
piece	O
of	O
memory	O
is	O
freed	O
while	O
there	O
are	O
still	O
pointers	O
to	O
it	O
,	O
and	O
one	O
of	O
those	O
pointers	O
is	O
dereferenced	O
.	O
</s>
<s>
Double	O
free	O
bugs	B-Error_Name
,	O
which	O
occur	O
when	O
the	O
program	O
tries	O
to	O
free	O
a	O
region	O
of	O
memory	O
that	O
has	O
already	O
been	O
freed	O
,	O
and	O
perhaps	O
already	O
been	O
allocated	O
again	O
.	O
</s>
<s>
Certain	O
kinds	O
of	O
memory	B-Error_Name
leaks	I-Error_Name
,	O
in	O
which	O
a	O
program	O
fails	O
to	O
free	O
memory	O
occupied	O
by	O
objects	O
that	O
have	O
become	O
unreachable	B-General_Concept
,	O
which	O
can	O
lead	O
to	O
memory	O
exhaustion	O
.	O
</s>
<s>
A	O
peer-reviewed	O
paper	O
from	O
2005	O
concluded	O
that	O
GC	O
needs	O
five	O
times	O
the	O
memory	O
to	O
compensate	O
for	O
this	O
overhead	O
and	O
to	O
perform	O
as	O
fast	O
as	O
the	O
same	O
program	O
using	O
idealised	O
explicit	O
memory	B-General_Concept
management	I-General_Concept
.	O
</s>
<s>
The	O
comparison	O
however	O
is	O
made	O
to	O
a	O
program	O
generated	O
by	O
inserting	O
deallocation	B-General_Concept
calls	O
using	O
an	O
oracle	O
,	O
implemented	O
by	O
collecting	O
traces	O
from	O
programs	O
run	O
under	O
a	O
profiler	O
,	O
and	O
the	O
program	O
is	O
only	O
correct	O
for	O
one	O
particular	O
execution	O
of	O
the	O
program	O
.	O
</s>
<s>
The	O
impact	O
on	O
performance	O
was	O
given	O
by	O
Apple	O
as	O
a	O
reason	O
for	O
not	O
adopting	O
garbage	B-General_Concept
collection	I-General_Concept
in	O
iOS	B-Application
,	O
despite	O
it	O
being	O
the	O
most	O
desired	O
feature	O
.	O
</s>
<s>
The	O
moment	O
when	O
the	O
garbage	B-General_Concept
is	O
actually	O
collected	O
can	O
be	O
unpredictable	O
,	O
resulting	O
in	O
stalls	O
(	O
pauses	O
to	O
shift/free	O
memory	O
)	O
scattered	O
throughout	O
a	O
session	O
.	O
</s>
<s>
Unpredictable	O
stalls	O
can	O
be	O
unacceptable	O
in	O
real-time	O
environments	O
,	O
in	O
transaction	B-General_Concept
processing	I-General_Concept
,	O
or	O
in	O
interactive	O
programs	O
.	O
</s>
<s>
Incremental	O
,	O
concurrent	O
,	O
and	O
real-time	O
garbage	B-General_Concept
collectors	I-General_Concept
address	O
these	O
problems	O
,	O
with	O
varying	O
trade-offs	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
</s>
<s>
The	O
overall	O
strategy	O
consists	O
of	O
determining	O
which	O
objects	O
should	O
be	O
garbage	B-General_Concept
collected	I-General_Concept
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
root	O
objects	O
,	O
and	O
considering	O
the	O
rest	O
as	O
garbage	B-General_Concept
and	O
collecting	O
them	O
.	O
</s>
<s>
Reference	B-General_Concept
counting	I-General_Concept
garbage	B-General_Concept
collection	I-General_Concept
is	O
where	O
each	O
object	O
has	O
a	O
count	O
of	O
the	O
number	O
of	O
references	O
to	O
it	O
.	O
</s>
<s>
Garbage	B-General_Concept
is	O
identified	O
by	O
having	O
a	O
reference	B-General_Concept
count	I-General_Concept
of	O
zero	O
.	O
</s>
<s>
An	O
object	O
's	O
reference	B-General_Concept
count	I-General_Concept
is	O
incremented	O
when	O
a	O
reference	O
to	O
it	O
is	O
created	O
,	O
and	O
decremented	O
when	O
a	O
reference	O
is	O
destroyed	O
.	O
</s>
<s>
As	O
with	O
manual	B-Application
memory	I-Application
management	I-Application
,	O
and	O
unlike	O
tracing	B-General_Concept
garbage	I-General_Concept
collection	I-General_Concept
,	O
reference	B-General_Concept
counting	I-General_Concept
guarantees	O
that	O
objects	O
are	O
destroyed	O
as	O
soon	O
as	O
their	O
last	O
reference	O
is	O
destroyed	O
,	O
and	O
usually	O
only	O
accesses	O
memory	O
which	O
is	O
either	O
in	O
CPU	B-General_Concept
caches	I-General_Concept
,	O
in	O
objects	O
to	O
be	O
freed	O
,	O
or	O
directly	O
pointed	O
to	O
by	O
those	O
,	O
and	O
thus	O
tends	O
to	O
not	O
have	O
significant	O
negative	O
side	O
effects	O
on	O
CPU	B-General_Concept
cache	I-General_Concept
and	O
virtual	B-Architecture
memory	I-Architecture
operation	O
.	O
</s>
<s>
There	O
are	O
a	O
number	O
of	O
disadvantages	O
to	O
reference	B-General_Concept
counting	I-General_Concept
;	O
this	O
can	O
generally	O
be	O
solved	O
or	O
mitigated	O
by	O
more	O
sophisticated	O
algorithms	O
:	O
</s>
<s>
Cycles	O
If	O
two	O
or	O
more	O
objects	O
refer	O
to	O
each	O
other	O
,	O
they	O
can	O
create	O
a	O
cycle	O
whereby	O
neither	O
will	O
be	O
collected	O
as	O
their	O
mutual	O
references	O
never	O
let	O
their	O
reference	B-General_Concept
counts	I-General_Concept
become	O
zero	O
.	O
</s>
<s>
Some	O
garbage	B-General_Concept
collection	I-General_Concept
systems	O
using	O
reference	B-General_Concept
counting	I-General_Concept
(	O
like	O
the	O
one	O
in	O
CPython	B-Language
)	O
use	O
specific	O
cycle-detecting	O
algorithms	O
to	O
deal	O
with	O
this	O
issue	O
.	O
</s>
<s>
Another	O
strategy	O
is	O
to	O
use	O
weak	B-General_Concept
references	I-General_Concept
for	O
the	O
"	O
backpointers	O
"	O
which	O
create	O
cycles	O
.	O
</s>
<s>
Under	O
reference	B-General_Concept
counting	I-General_Concept
,	O
a	O
weak	B-General_Concept
reference	I-General_Concept
is	O
similar	O
to	O
a	O
weak	B-General_Concept
reference	I-General_Concept
under	O
a	O
tracing	B-General_Concept
garbage	I-General_Concept
collector	I-General_Concept
.	O
</s>
<s>
It	O
is	O
a	O
special	O
reference	O
object	O
whose	O
existence	O
does	O
not	O
increment	O
the	O
reference	B-General_Concept
count	I-General_Concept
of	O
the	O
referent	O
object	O
.	O
</s>
<s>
Furthermore	O
,	O
a	O
weak	B-General_Concept
reference	I-General_Concept
is	O
safe	O
in	O
that	O
when	O
the	O
referent	O
object	O
becomes	O
garbage	B-General_Concept
,	O
any	O
weak	B-General_Concept
reference	I-General_Concept
to	O
it	O
lapses	O
,	O
rather	O
than	O
being	O
permitted	O
to	O
remain	O
dangling	O
,	O
meaning	O
that	O
it	O
turns	O
into	O
a	O
predictable	O
value	O
,	O
such	O
as	O
a	O
null	O
reference	O
.	O
</s>
<s>
Space	O
overhead	O
(	O
reference	B-General_Concept
count	I-General_Concept
)	O
Reference	B-General_Concept
counting	I-General_Concept
requires	O
space	O
to	O
be	O
allocated	O
for	O
each	O
object	O
to	O
store	O
its	O
reference	B-General_Concept
count	I-General_Concept
.	O
</s>
<s>
The	O
count	O
may	O
be	O
stored	O
adjacent	O
to	O
the	O
object	O
's	O
memory	O
or	O
in	O
a	O
side	O
table	O
somewhere	O
else	O
,	O
but	O
in	O
either	O
case	O
,	O
every	O
single	O
reference-counted	O
object	O
requires	O
additional	O
storage	O
for	O
its	O
reference	B-General_Concept
count	I-General_Concept
.	O
</s>
<s>
Memory	O
space	O
with	O
the	O
size	O
of	O
an	O
unsigned	O
pointer	O
is	O
commonly	O
used	O
for	O
this	O
task	O
,	O
meaning	O
that	O
32	O
or	O
64	O
bits	O
of	O
reference	B-General_Concept
count	I-General_Concept
storage	O
must	O
be	O
allocated	O
for	O
each	O
object	O
.	O
</s>
<s>
On	O
some	O
systems	O
,	O
it	O
may	O
be	O
possible	O
to	O
mitigate	O
this	O
overhead	O
by	O
using	O
a	O
tagged	O
pointer	O
to	O
store	O
the	O
reference	B-General_Concept
count	I-General_Concept
in	O
unused	O
areas	O
of	O
the	O
object	O
's	O
memory	O
.	O
</s>
<s>
If	O
an	O
object	O
reliably	O
has	O
a	O
pointer	O
at	O
a	O
certain	O
location	O
,	O
the	O
reference	B-General_Concept
count	I-General_Concept
can	O
be	O
stored	O
in	O
the	O
unused	O
bits	O
of	O
the	O
pointer	O
.	O
</s>
<s>
For	O
example	O
,	O
each	O
object	O
in	O
Objective-C	B-Language
has	O
a	O
pointer	O
to	O
its	O
class	O
at	O
the	O
beginning	O
of	O
its	O
memory	O
;	O
on	O
the	O
ARM64	B-Architecture
architecture	O
using	O
iOS	B-Operating_System
7	I-Operating_System
,	O
19	O
unused	O
bits	O
of	O
this	O
class	O
pointer	O
are	O
used	O
to	O
store	O
the	O
object	O
's	O
reference	B-General_Concept
count	I-General_Concept
.	O
</s>
<s>
Reference	B-General_Concept
counting	I-General_Concept
in	O
C++	B-Language
is	O
usually	O
implemented	O
using	O
"	O
smart	B-Language
pointers	I-Language
"	O
whose	O
constructors	O
,	O
destructors	B-Language
and	O
assignment	O
operators	O
manage	O
the	O
references	O
.	O
</s>
<s>
A	O
smart	B-Language
pointer	I-Language
can	O
be	O
passed	O
by	O
reference	O
to	O
a	O
function	O
,	O
which	O
avoids	O
the	O
need	O
to	O
copy-construct	O
a	O
new	O
smart	B-Language
pointer	I-Language
(	O
which	O
would	O
increase	O
the	O
reference	B-General_Concept
count	I-General_Concept
on	O
entry	O
into	O
the	O
function	O
and	O
decrease	O
it	O
on	O
exit	O
)	O
.	O
</s>
<s>
Instead	O
the	O
function	O
receives	O
a	O
reference	O
to	O
the	O
smart	B-Language
pointer	I-Language
which	O
is	O
produced	O
inexpensively	O
.	O
</s>
<s>
The	O
Deutsch-Bobrow	O
method	B-Language
of	O
reference	B-General_Concept
counting	I-General_Concept
capitalizes	O
on	O
the	O
fact	O
that	O
most	O
reference	B-General_Concept
count	I-General_Concept
updates	O
are	O
in	O
fact	O
generated	O
by	O
references	O
stored	O
in	O
local	O
variables	O
.	O
</s>
<s>
It	O
ignores	O
these	O
references	O
,	O
only	O
counting	O
references	O
in	O
the	O
heap	B-Application
,	O
but	O
before	O
an	O
object	O
with	O
reference	B-General_Concept
count	I-General_Concept
zero	O
can	O
be	O
deleted	O
,	O
the	O
system	O
must	O
verify	O
with	O
a	O
scan	O
of	O
the	O
stack	O
and	O
registers	O
that	O
no	O
other	O
reference	O
to	O
it	O
still	O
exists	O
.	O
</s>
<s>
A	O
reference	B-General_Concept
counting	I-General_Concept
algorithm	O
would	O
typically	O
execute	O
rc(O1 )	O
--	O
,	O
rc(O2 )	O
++	O
,	O
rc(O2 )	O
--	O
,	O
rc(O3 )	O
++	O
,	O
rc(O3 )	O
--	O
,	O
...	O
,	O
rc(On )	O
++	O
.	O
</s>
<s>
In	O
order	O
to	O
have	O
the	O
reference	B-General_Concept
count	I-General_Concept
properly	O
evaluated	O
at	O
the	O
end	O
of	O
the	O
interval	O
it	O
is	O
enough	O
to	O
perform	O
rc(O1 )	O
--	O
and	O
rc(On )	O
++	O
.	O
</s>
<s>
Levanoni	O
and	O
Petrank	O
measured	O
an	O
elimination	O
of	O
more	O
than	O
99%	O
of	O
the	O
counter	O
updates	O
in	O
typical	O
Java	B-Language
benchmarks	O
.	O
</s>
<s>
Requires	O
atomicity	B-General_Concept
When	O
used	O
in	O
a	O
multithreaded	B-Operating_System
environment	O
,	O
these	O
modifications	O
(	O
increment	O
and	O
decrement	O
)	O
may	O
need	O
to	O
be	O
atomic	B-General_Concept
operations	I-General_Concept
such	O
as	O
compare-and-swap	B-Operating_System
,	O
at	O
least	O
for	O
any	O
objects	O
which	O
are	O
shared	O
,	O
or	O
potentially	O
shared	O
among	O
multiple	O
threads	B-Operating_System
.	O
</s>
<s>
Atomic	B-General_Concept
operations	I-General_Concept
are	O
expensive	O
on	O
a	O
multiprocessor	O
,	O
and	O
even	O
more	O
expensive	O
if	O
they	O
have	O
to	O
be	O
emulated	O
with	O
software	O
algorithms	O
.	O
</s>
<s>
It	O
is	O
possible	O
to	O
avoid	O
this	O
issue	O
by	O
adding	O
per-thread	O
or	O
per-CPU	O
reference	B-General_Concept
counts	I-General_Concept
and	O
only	O
accessing	O
the	O
global	O
reference	B-General_Concept
count	I-General_Concept
when	O
the	O
local	O
reference	B-General_Concept
counts	I-General_Concept
become	O
or	O
are	O
no	O
longer	O
zero	O
(	O
or	O
,	O
alternatively	O
,	O
using	O
a	O
binary	O
tree	O
of	O
reference	B-General_Concept
counts	I-General_Concept
,	O
or	O
even	O
giving	O
up	O
deterministic	O
destruction	O
in	O
exchange	O
for	O
not	O
having	O
a	O
global	O
reference	B-General_Concept
count	I-General_Concept
at	O
all	O
)	O
,	O
but	O
this	O
adds	O
significant	O
memory	O
overhead	O
and	O
thus	O
tends	O
to	O
be	O
only	O
useful	O
in	O
special	O
cases	O
(	O
it	O
is	O
used	O
,	O
for	O
example	O
,	O
in	O
the	O
reference	B-General_Concept
counting	I-General_Concept
of	O
Linux	O
kernel	O
modules	O
)	O
.	O
</s>
<s>
Update	O
coalescing	O
by	O
Levanoni	O
and	O
Petrank	O
can	O
be	O
used	O
to	O
eliminate	O
all	O
atomic	B-General_Concept
operations	I-General_Concept
from	O
the	O
write-barrier	O
.	O
</s>
<s>
Counters	O
are	O
never	O
updated	O
by	O
the	O
program	B-Operating_System
threads	I-Operating_System
in	O
the	O
course	O
of	O
program	O
execution	O
.	O
</s>
<s>
They	O
are	O
only	O
modified	O
by	O
the	O
collector	O
which	O
executes	O
as	O
a	O
single	O
additional	O
thread	B-Operating_System
with	O
no	O
synchronization	O
.	O
</s>
<s>
This	O
method	B-Language
can	O
be	O
used	O
as	O
a	O
stop-the-world	O
mechanism	O
for	O
parallel	O
programs	O
,	O
and	O
also	O
with	O
a	O
concurrent	O
reference	B-General_Concept
counting	I-General_Concept
collector	O
.	O
</s>
<s>
Not	O
real-time	O
Naive	O
implementations	O
of	O
reference	B-General_Concept
counting	I-General_Concept
do	O
not	O
generally	O
provide	O
real-time	O
behavior	O
,	O
because	O
any	O
pointer	O
assignment	O
can	O
potentially	O
cause	O
a	O
number	O
of	O
objects	O
bounded	O
only	O
by	O
total	O
allocated	O
memory	O
size	O
to	O
be	O
recursively	O
freed	O
while	O
the	O
thread	B-Operating_System
is	O
unable	O
to	O
perform	O
other	O
work	O
.	O
</s>
<s>
It	O
is	O
possible	O
to	O
avoid	O
this	O
issue	O
by	O
delegating	O
the	O
freeing	O
of	O
unreferenced	O
objects	O
to	O
other	O
threads	B-Operating_System
,	O
at	O
the	O
cost	O
of	O
extra	O
overhead	O
.	O
</s>
<s>
Escape	O
analysis	O
is	O
a	O
compile-time	O
technique	O
that	O
can	O
convert	O
heap	B-Application
allocations	I-Application
to	O
stack	B-General_Concept
allocations	I-General_Concept
,	O
thereby	O
reducing	O
the	O
amount	O
of	O
garbage	B-General_Concept
collection	I-General_Concept
to	O
be	O
done	O
.	O
</s>
<s>
If	O
a	O
function-local	O
allocation	O
is	O
found	O
to	O
be	O
accessible	O
to	O
another	O
function	O
or	O
thread	B-Operating_System
,	O
the	O
allocation	O
is	O
said	O
to	O
"	O
escape	O
"	O
and	O
cannot	O
be	O
done	O
on	O
the	O
stack	O
.	O
</s>
<s>
Otherwise	O
,	O
the	O
object	O
may	O
be	O
allocated	O
directly	O
on	O
the	O
stack	O
and	O
released	O
when	O
the	O
function	O
returns	O
,	O
bypassing	O
the	O
heap	B-Application
and	O
associated	O
memory	B-General_Concept
management	I-General_Concept
costs	O
.	O
</s>
<s>
Generally	O
speaking	O
,	O
higher-level	O
programming	O
languages	O
are	O
more	O
likely	O
to	O
have	O
garbage	B-General_Concept
collection	I-General_Concept
as	O
a	O
standard	O
feature	O
.	O
</s>
<s>
In	O
some	O
languages	O
lacking	O
built	O
in	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
it	O
can	O
be	O
added	O
through	O
a	O
library	O
,	O
as	O
with	O
the	O
Boehm	B-Language
garbage	I-Language
collector	I-Language
for	O
C	B-Language
and	O
C++	B-Language
.	O
</s>
<s>
Most	O
functional	B-Language
programming	I-Language
languages	I-Language
,	O
such	O
as	O
ML	B-Language
,	O
Haskell	B-Language
,	O
and	O
APL	B-Language
,	O
have	O
garbage	B-General_Concept
collection	I-General_Concept
built	O
in	O
.	O
</s>
<s>
Lisp	B-Language
is	O
especially	O
notable	O
as	O
both	O
the	O
first	O
functional	B-Language
programming	I-Language
language	I-Language
and	O
the	O
first	O
language	O
to	O
introduce	O
garbage	B-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
Other	O
dynamic	O
languages	O
,	O
such	O
as	O
Ruby	B-Language
and	O
Julia	B-Application
(	O
but	O
not	O
Perl5	B-Language
or	O
PHP	B-Application
before	O
version	O
5.3	O
,	O
which	O
both	O
use	O
reference	B-General_Concept
counting	I-General_Concept
)	O
,	O
JavaScript	B-Language
and	O
ECMAScript	B-Language
also	O
tend	O
to	O
use	O
GC	O
.	O
</s>
<s>
Object-oriented	B-Language
programming	I-Language
languages	I-Language
such	O
as	O
Smalltalk	B-Application
,	O
RPL	B-Device
and	O
Java	B-Language
usually	O
provide	O
integrated	O
garbage	B-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
Notable	O
exceptions	O
are	O
C++	B-Language
and	O
Delphi	B-Language
,	O
which	O
have	O
destructors	B-Language
.	O
</s>
<s>
BASIC	O
and	O
Logo	B-Device
have	O
often	O
used	O
garbage	B-General_Concept
collection	I-General_Concept
for	O
variable-length	O
data	O
types	O
,	O
such	O
as	O
strings	O
and	O
lists	O
,	O
so	O
as	O
not	O
to	O
burden	O
programmers	O
with	O
memory	B-General_Concept
management	I-General_Concept
details	O
.	O
</s>
<s>
On	O
the	O
Altair	B-Architecture
8800	I-Architecture
,	O
programs	O
with	O
many	O
string	O
variables	O
and	O
little	O
string	O
space	O
could	O
cause	O
long	O
pauses	O
due	O
to	O
garbage	B-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
Similarly	O
the	O
Applesoft	B-Language
BASIC	I-Language
interpreter	O
's	O
garbage	B-General_Concept
collection	I-General_Concept
algorithm	O
repeatedly	O
scans	O
the	O
string	O
descriptors	O
for	O
the	O
string	O
having	O
the	O
highest	O
address	O
in	O
order	O
to	O
compact	O
it	O
toward	O
high	O
memory	O
,	O
resulting	O
in	O
performance	O
and	O
pauses	O
anywhere	O
from	O
a	O
few	O
seconds	O
to	O
a	O
few	O
minutes	O
.	O
</s>
<s>
A	O
replacement	O
garbage	B-General_Concept
collector	I-General_Concept
for	O
Applesoft	B-Language
BASIC	I-Language
by	O
Randy	O
Wigginton	O
identifies	O
a	O
group	O
of	O
strings	O
in	O
every	O
pass	O
over	O
the	O
heap	B-Application
,	O
reducing	O
collection	O
time	O
dramatically	O
.	O
</s>
<s>
BASIC.System	O
,	O
released	O
with	O
ProDOS	B-Operating_System
in	O
1983	O
,	O
provides	O
a	O
windowing	O
garbage	B-General_Concept
collector	I-General_Concept
for	O
BASIC	O
that	O
is	O
many	O
times	O
faster	O
.	O
</s>
<s>
While	O
the	O
Objective-C	B-Language
traditionally	O
had	O
no	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
with	O
the	O
release	O
of	O
OS	O
X	O
10.5	O
in	O
2007	O
Apple	O
introduced	O
garbage	B-General_Concept
collection	I-General_Concept
for	O
Objective-C2.0	O
,	O
using	O
an	O
in-house	O
developed	O
runtime	O
collector	O
.	O
</s>
<s>
However	O
,	O
with	O
the	O
2012	O
release	O
of	O
OS	O
X	O
10.8	O
,	O
garbage	B-General_Concept
collection	I-General_Concept
was	O
deprecated	O
in	O
favor	O
of	O
LLVM	B-Application
's	O
automatic	B-Language
reference	I-Language
counter	I-Language
(	O
ARC	O
)	O
that	O
was	O
introduced	O
with	O
OS	O
X	O
10.7	O
.	O
</s>
<s>
Furthermore	O
,	O
since	O
May	O
2015	O
Apple	O
even	O
forbids	O
the	O
usage	O
of	O
garbage	B-General_Concept
collection	I-General_Concept
for	O
new	O
OSX	O
applications	O
in	O
the	O
App	B-Application
Store	I-Application
.	O
</s>
<s>
For	O
iOS	B-Application
,	O
garbage	B-General_Concept
collection	I-General_Concept
has	O
never	O
been	O
introduced	O
due	O
to	O
problems	O
in	O
application	O
responsivity	O
and	O
performance	O
;	O
instead	O
,	O
iOS	B-Application
uses	O
ARC	O
.	O
</s>
<s>
Garbage	B-General_Concept
collection	I-General_Concept
is	O
rarely	O
used	O
on	O
embedded	B-Architecture
or	O
real-time	B-General_Concept
systems	I-General_Concept
because	O
of	O
the	O
usual	O
need	O
for	O
very	O
tight	O
control	O
over	O
the	O
use	O
of	O
limited	O
resources	O
.	O
</s>
<s>
However	O
,	O
garbage	B-General_Concept
collectors	I-General_Concept
compatible	O
with	O
many	O
limited	O
environments	O
have	O
been	O
developed	O
.	O
</s>
<s>
The	O
Microsoft	O
.NET	B-Application
Micro	I-Application
Framework	I-Application
,	O
.NET	O
nanoFramework	O
and	O
Java	B-Language
Platform	I-Language
,	I-Language
Micro	I-Language
Edition	I-Language
are	O
embedded	B-Architecture
software	O
platforms	O
that	O
,	O
like	O
their	O
larger	O
cousins	O
,	O
include	O
garbage	B-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
Garbage	B-General_Concept
collectors	I-General_Concept
available	O
in	O
Java	B-Language
JDKs	O
include	O
:	O
</s>
<s>
Compile-time	O
garbage	B-General_Concept
collection	I-General_Concept
is	O
a	O
form	O
of	O
static	O
analysis	O
allowing	O
memory	O
to	O
be	O
reused	O
and	O
reclaimed	O
based	O
on	O
invariants	O
known	O
during	O
compilation	B-Language
.	O
</s>
<s>
This	O
form	O
of	O
garbage	B-General_Concept
collection	I-General_Concept
has	O
been	O
studied	O
in	O
the	O
Mercury	B-Operating_System
programming	I-Operating_System
language	I-Operating_System
,	O
and	O
it	O
saw	O
greater	O
usage	O
with	O
the	O
introduction	O
of	O
LLVM	B-Application
's	O
automatic	B-Language
reference	I-Language
counter	I-Language
(	O
ARC	O
)	O
into	O
Apple	O
's	O
ecosystem	O
(	O
iOS	B-Application
and	O
OSX	O
)	O
in	O
2011	O
.	O
</s>
<s>
Incremental	O
,	O
concurrent	O
,	O
and	O
real-time	O
garbage	B-General_Concept
collectors	I-General_Concept
have	O
been	O
developed	O
,	O
for	O
example	O
by	O
Henry	O
Baker	O
and	O
by	O
Henry	O
Lieberman	O
.	O
</s>
<s>
When	O
it	O
becomes	O
half	O
full	O
,	O
a	O
garbage	B-General_Concept
collection	I-General_Concept
is	O
performed	O
which	O
moves	O
the	O
live	O
objects	O
into	O
the	O
other	O
half	O
and	O
the	O
remaining	O
objects	O
are	O
implicitly	O
deallocated	O
.	O
</s>
<s>
Generational	O
garbage	B-General_Concept
collection	I-General_Concept
schemes	O
are	O
based	O
on	O
the	O
empirical	O
observation	O
that	O
most	O
objects	O
die	O
young	O
.	O
</s>
<s>
In	O
generational	O
garbage	B-General_Concept
collection	I-General_Concept
two	O
or	O
more	O
allocation	O
regions	O
(	O
generations	O
)	O
are	O
kept	O
,	O
which	O
are	O
kept	O
separate	O
based	O
on	O
object	O
's	O
age	O
.	O
</s>
<s>
Some	O
high-level	B-Architecture
language	I-Architecture
computer	I-Architecture
architectures	I-Architecture
include	O
hardware	O
support	O
for	O
real-time	O
garbage	B-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
Most	O
implementations	O
of	O
real-time	O
garbage	B-General_Concept
collectors	I-General_Concept
use	O
tracing	O
.	O
</s>
<s>
Such	O
real-time	O
garbage	B-General_Concept
collectors	I-General_Concept
meet	O
hard	O
real-time	O
constraints	O
when	O
used	O
with	O
a	O
real-time	O
operating	O
system	O
.	O
</s>
