
Garbage Collection Techniques
Notes by Bogdan Stroe
The paper covers the main algorithms for garbage collecting. First are described the basic
techniques, and performances problems of these algorithms are discussed. Next are
presented refinements of basic algorithms, with the final goal of obtaining a functional
real time garbage collecting system.
Next, we present a summary of each section of the paper:
1. Introduction
- application GB’s;
- GB in programming languages;
- support from compiler;
- the two phase abstraction: garbage detection and reclaiming the garbage;
- garbage detection based on reachability from a root set;
- the root set contains globally visible variables of active procedures and local
variables of active procedures, and the registers used by active procedures;
- assumption: RTT information;
2. Basic GC techniques
- three approaches: reference counting, marking, copying.
2.1 Reference counting
Advantages: incremental in nature;
Problems: efficiency (cost per program instruction, short lived variables) and
effectiveness (cycles);
2.2 Mark-Sweep Collection
- two phases: marking the reachable graph and reclaiming the garbage (usually into
free lists;
Problems: fragmentation (possible solution is keeping free lists for different
sizes), cost of collection is proportional with the size of the heap, and locality of
reference.
2.3 Mark-Compact Collection
- live objects are compacted together, the rest of the space is free;
- advantages: no fragmentation, easy allocation, improved locality;
- problems: several (two or three) passes through the whole heap;
2.4 Copying Garbage Collection
- heap divided in two contiguous semispaces;