Recently I had a few performance problems with an application that required JVM GC monitoring. It had been so long since the last time I'd had to perform any CG analysis that I had to remind myself of what to do!
However, now that I've reminded myself there's no better place to document it than here:
Using jps and jstat to get JVM GC statistics
- Ensure that JDK bin directory is on your path
- Issue command 'jps' to find the running JVM's PID ( it will show all running java processes ).
- Once you have identifed the PID issue command 'jstat -gcutil [PID] 5000', replacing [PID] with the one identified above
- Now the console should update on a 5 second basis with statistics.
Fields available in jstat gcutil output
Basically, the first set of columns (S0, S1, E, O, P) describes the utilisation of the various memory heaps (Survivor heaps, Eden - young generation, Old generation and Perm. heap space).
Next, (YGC and YGCT) show the number of young (eden) space collections and total time taken so far doing these collections.
Columns (FCG, FGCT) show the number and time taken doing old space collections.
Lastly, GCT shows the total time taken performing garbage collection so far.
This guide only breaks the surface of what output you can get from jstat; the sun website provides a more complete guide to JVM 1.5 monitoring tools. Also, I'm assuming that you are using the default garbage collector - if not the columns output may vary.
Once you've established that there is a problem
Basically, you need to analyse which heap is being used up and attempt to perform JVM GC tuning.