Next: Optimal Throughput GC policy


Garbage collector

 

+

Search Tips   |   Advanced Search

The garbage collector...

Garbage collection only occurs when...

When an allocation failure occurs, the running thread that had the failure takes exclusive control of the VM. All application threads stop and garbage collection commences. This is referred to as a stop-the-world event.

The process of garbage collection consists of three phases:

Mark phase all reachable objects are identified and all else is considered garbage.
Sweep phase space used by all unmarked objects is reclaimed.
Compaction phase objects are moved into as contiguous a space as possible and references are updated.

The compaction phase is the most costly because objects are moved and therefore require all references to them to be updated as well. Thus, compaction is always avoided if possible.


See also

  1. Java Technology; IBM Style: Garbage collection policies, Part 1
  2. Java Technology; IBM Style; Garbage Collection policies, Part 2