One of the compelling features of Java is its support for memory management
by means of a garbage collector that 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 is a performance bottleneck, because the application
spends too much time with garbage collection. In those cases, it
is helpful to understand the garbage collector’s functionality and to know
how to control its behavior. The Sun JVM offers a number of JVM switches
that allow GC tuning.
In this tutorial we will explain 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.