jstat

jstat (Java Virtual Machine Statistics Monitoring Tool) is a console tool that displays performance statistics for a JVM.

The –gcutil option identifies whether the JVM is spending a lot of time garbage collecting due to low memory. For example, the following command attaches to process 21891 and takes 7 samples at 250 millisecond intervals:

jstat -gcutil 21891 250 7

  S0     S1     E      O      P     YGC    YGCT    FGC    FGCT     GCT
 12.44   0.00  27.20   9.49  96.70    78    0.176     5    0.495    0.672
 12.44   0.00  62.16   9.49  96.70    78    0.176     5    0.495    0.672
 12.44   0.00  83.97   9.49  96.70    78    0.176     5    0.495    0.672

FGC (the number of full GC events) is an indicator of how busy the JVM is doing garbage collection. If this number increases quickly (for example, every 15 or 30 seconds or more frequently), it indicates memory issues.

The above output also indicates the eden (E), old (O) and permgen (P) memory % utilization.

For more information, see http://docs.oracle.com/javase/6/docs/technotes/tools/share/jstat.html.