Saturday, March 26, 2011

Java Profiling

Before you make changes to an existing Java application it is a good idea to profile its performance. After the changes you should profile the application again to make sure that the changes you just introduced does not severely affect the overall performance.

Some tools that I have worked with:

JConsole
Apply this parameter when starting the JVM of the application being profiled:
-Dcom.sun.management.jmxremote


JVisualVM
Available with Sun JDK version 6. It can be used to profile a pre-6 JVM but certain information and feature are unavailable, such as Heap Dump. There is no JVM parameter needed.

GC Viewer
This tool simply needs gc.log generated by a running JVM. Apply these parameters when starting the JVM:
-Xloggc:C:/temp/gcint.log -XX:+PrintGCDetails