Tuesday, 29 January 2013

Monitoring the GC

GCHisto for Offline Analysis of Garbage Collection Data

GCHisto is a tool designed to do offline analysis, it’s free and it’s hosted on http://java.net/projects/gchisto.
To run it you need to download it, cd into gchisto folder and type:
sudo ant run
You can then load any gc log file and this tool will give you a visual view on the log.
The tab “GC Pause stats” will help you to identify the duration of the young and full GC action.
The overhead column is useful to identify how good your GC is tuned. Documentations says that a concurrent GC should be less than 10% overhead (ideal is 1% or less). If it’s above 10% it may required some tuning (increase the heap space can be one).

It will also provide useful graphs which are always better and less boring the raw data:

The GC Pause Distribution is used to analyse how many pauses occurs and how they are distributed:

a more detailed guide on all the gchisto features can be found here : http://sysadminsjourney.com/2008/09/15/profile-gc-with-gchisto/

Visual GC plugin + VisualVM for Live Analysis of Garbage Collection Data

In case you want to monitor what’s happening in the GC in real time you can use the visualVM that come together with your jdk.
To run it just type
To add the viusualGC click on Tools–>Plugins–>Available plugins and select and install Visual GC
Restart visual VM.
With the basic VisualVM you can monitor memory usage, CPU consumption and how the Threads behave. The visual GC gives you a realtime view on the 3 heap memory spaces usage.

As you can see, a full and immediate vision on the Permanent, old and young space is given, helping a lot during analysis.
You can use this tool locally without any other required step, but it’s also possible to monitor remote VM (UAT,SYS,etc) using the jstatd deamon provided by java in sdk (same place where the jvisualvm is).
The jstatd daemon launches a Java RMI server application that watches for the creation and termination of HotSpot VMs and provides an interface to allow remote monitoring tools such as VisualVM to attach and monitor Java applications remotely, here is how to use it and configure it : http://docs.oracle.com/javase/6/docs/technotes/tools/share/jstatd.html
Hope this will help you a bit guys!

No comments:

Post a Comment