Java 2 SDK for Solaris Developer's Guide

Interpreting -verbosegc Output

Troubleshooting Garbage Collection

Use -verbosegc to determine whether your application has garbage-collected only young space or both young and old space (complete). Run the option as follows:


% java -verbosegc

This action would produce output similar to the following:


GC[1] in 305 ms: (6144kb, 6% free) -> (14Mb, 61% free)

In this case GC[1] indicates a complete garbage collection. GC[0] would indicate a young space only garbage collection. The collection took 305ms. At the start of the collection there was a 6144KByte heap with 6% free. The heap expanded during collection and at the end of the collection there was a 14MByte heap with 61% free.

Generational Heap Sizes

The heap is divided into a young generation and an old generation. For the sizes of each of the generations, use the following command.


% java -verbosegc -verbosegc

Sample Output

Examine the following sample output of -verbosegc -verbosegc:


Gen0(semi-spaces): size=4096kb, free=0kb, maxAlloc=0kb
  From space: size=524288 words, used=524286 words, free=2
  To space:   size=524288 words, used=1 words, free=524287
Gen0(semi-spaces)-GC #4 tenure-thresh=0 61ms 0%->28% free
Gen0(semi-spaces): size=4096kb, free=571kb, maxAlloc=571kb
  From space: size=524288 words, used=378157 words, free=146131
  To space:   size=524288 words, used=1 words, free=524287
Gen1(mark-compact): size=4096kb, free=0kb, maxAlloc=0kb
Gen1(mark-compact)-GC #1 Gen1: 850kb dense
 262ms 0%->2% free
Gen1(mark-compact): size=4096kb, free=80kb, maxAlloc=80kb

From this output, you can derive the following information about each generation:

Gen0 is a semi-space copying collector that started at 4096 KBytes. Before the young space collection there was 0 Kb of free memory; after the young space collection there were 378157 words free (28%). Gen1 is a mark-compact collector, which freed 2% during the collection.

A -verbosegc -verbosegc -verbosegc mode gives even more information.