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!
First, ensure that an appropriate JDK is on your path
[dave@titan ~]$ java -version java version "1.7.0_45" OpenJDK Runtime Environment (fedora-22.214.171.124.fc19-x86_64 u45-b15) OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
Next, issue the command
jps which shows a list of all running Java processes that can be interrogated.
[dave@titan ~]$ jps 2472 RemoteMavenServer 3189 Jps 2364 Main
Once you have identified the PID issue the following command:
jstat -gcutil [PID] [Frequency ms] [Iterations]
jstatloops until it gets a signal.
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 Permanent 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 Oracle website provides complete documentation for jstat. Also, I'm assuming that you are using the default garbage collector - if not the columns output may vary.