One of the compelling features of Java is its support for memory management
by means of a garbage collector, which automatically releases heap memory
that is no longer used. Usually, Java programmers don’t care a lot about
the garbage collector and treat it as a black box that simply does its
job. However, garbage collection does not come for free; it takes
time and consumes resources. Occasionally, it turns out that the
garbage collector contributes to the performance degradation of an application;
basically the application spends more time with garbage collection than
necessary. In those cases, it is helpful to understand the garbage
collector’s functionality and to know how to control and tune its behavior.
In this tutorial we will first give an overview of the classic garbage
collection algorithms (reference counting, mark & sweep, mark &
compact, copying, generational, incremental, and concurrent GC) before
we delve into the more practical issue of exploring the tuning options
that the Sun JVM has to offer. This includes new tuning options introduced
in Java 5.0 as "garbage collector ergonomics".