It is evident that the process gives a brief overview of some tools that assist you in analysing the heap utilization of your JVM. Depending on your environment a particular tool could be more suitable than others. Currently there are many hundreds of non functional tools available and there is no way that this section could provide a comprehensive overview of tool situation. Nevertheless it is intended to give a brief overview of different approaches and to reference supportive tools.
Instant visual analysis of GC by sun for testing firms. Visualgc directly connects to the JVM of your running application. There is no need to output the information into a logfile.
Visualgc is not included in the jdk any more. So download it from http://java.sun.com/performance/jvmstat/
In order to install it on Ubuntu uncompress the download to /usr/local/bin.
Edit ~/.bashrc in order to add the following two lines:
Run jps in order to look up the JVM id of your running application:
Connect visualgc to your application JVM to analyse garbage collection
For me in most cases connecting to the JVM with visualgc is not an option for various reasons. Mostly I run lots of performance tests and most of them have long durations 4-10 hours. Therefore I prefer to collect logfiles after the test has been completed and analyse them during post-processing. For the analysis of logfiles I maintain a Python script which recently had a complete overhaul.
To log information about heap utilization into a logfile the JVM offers you several parameters (see above). For the analysis I describe here I recommend the following configuration in addition to the memory configuration parameters:
The Python script that produces the diagrams for Gc analysis I used in this article you will find here together with a sample Java application for heap utilization: http://bitbucket.org/markfink/testing-software/src/tip/gcview/
The jstat utility is a statistics monitoring tool. It attaches to a Java VM and collects and logs performance statistics as specified by the command line options.
The jstat utility does not require the Java VM to be started with any special options. This utility is included in the JDK.
The following table lists the jstat command options.
- -class prints statistics on the behaviour of the class loader
- -compiler prints statistics on the behaviour of the Java compiler
- -gc prints statistics on the behaviour of the garbage collected heap
- -gccapacity prints statistics of the capacities of the generations and their corresponding spaces
- -gccause prints the summary of garbage collection statistics with the cause of the last and current (if applicable) garbage collection events
- -gcnew prints statistics of the behaviour of the new generation
- -gcnewcapacity prints statistics of the sizes of the new generations and their corresponding spaces
- -gcold prints statistics of the behaviour of the old and permanent generations
- -gcoldcapacity prints statistics of the sizes of the old generation
- prints statistics of the sizes of the permanent generation
- -gcutil prints a summary of garbage collection statistics
prints Java compilation method statistics