Thursday, August 31, 2006

Garbage Collectors in J2SE Platform version 1.5

In the J2SE Platform version 1.5 there are three additional collectors. Each is a generational collector which has been implemented to emphasize the throughput of the application or low garbage collection pause times.

  1. The throughput collector: this collector uses a parallel version of the young generation collector. It is used if the -XX:+UseParallelGC option is passed on the command line. The tenured generation collector is the same as the serial collector.

  2. The concurrent low pause collector: this collector is used if the -Xincgc or -XX:+UseConcMarkSweepGC is passed on the command line. The concurrent collector is used to collect the tenured generation and does most of the collection concurrently with the execution of the application. The application is paused for short periods during the collection. A parallel version of the young generation copying collector is used with the concurrent collector. The concurrent low pause collector is used if the option -XX:+UseConcMarkSweepGC is passed on the command line.

  3. The incremental (sometimes called train) low pause collector: this collector is used only if -XX:+UseTrainGC is passed on the command line. This collector has not changed since the J2SE Platform version 1.4.2 and is currently not under active development. It will not be supported in future releases.

Note that -XX:+UseParallelGC should not be used with -XX:+UseConcMarkSweepGC.

For more info refer here

Wednesday, August 30, 2006

Viewing GarbageCollection stats

The command line argument -verbose:gc prints information at every collection.
For example
[GC 325407K->83000K(776768K), 0.2300771 secs]
[GC 325816K->83372K(776768K), 0.2454258 secs]
[Full GC 267628K->83769K(776768K), 1.8479984 secs]
The flag -XX:+PrintGCDetails prints additional information about the collections.
example:
[GC [DefNew: 64575K->959K(64576K), 0.0457646 secs] 196016K->133633K(261184K), 0.0459067 secs]]
here
DefNew: 64575K->959K(64576K) indicates that the minor collection recovered about 98% of the young generation,

The flag -XX:+PrintGCTimeStamps will additionally print a time stamp at the start of each collection.