Java Reference
In-Depth Information
1. All GC algorithms divide the heap into old and young generations.
2. All GC algorithms employ a stop-the-world approach to clearing objects from the
young generation, which is usually a very quick operation.
GC Algorithms
The JVM provides four different algorithms for performing GC.
The serial garbage collector
The serial garbage collector is the simplest of the four. This is the default collector if the ap-
plication is running on a client-class machine (32-bit JVMs on Windows or single-processor
The serial collector uses a single thread to process the heap. It will stop all application
threads as the heap is processed (for either a minor or full GC). During a full GC, it will fully
compact the old generation.
The serial collector is enabled by using the -XX:+UseSerialGC flag (though usually it is the
default in those cases where it might be used). Note that unlike with most JVM flags, the
serial collector is not disabled by changing the plus sign to a minus sign (i.e., by specifying -
XX:-UseSerialGC ). On systems where the serial collector is the default, it is disabled by
specifying a different GC algorithm.
The throughput collector
This is the default collector for server-class machines (multi-CPU Unix machines, and any
64-bit JVM).
The throughput collector uses multiple threads to collect the young generation, which makes
minor GCs much faster than when the serial collector is used. The throughput collector can
use multiple threads to process the old generation as well. That is the default behavior in
JDK 7u4 and later releases, and that behavior can be enabled in earlier JDK 7 JVMs by spe-
cifying the -XX:+UseParallelOldGC flag. Because it uses multiple threads, the throughput
collector is often called the parallel collector.
Search WWH ::

Custom Search