Friday, June 5, 2009

JVM Profiling and Optimization

Caveat: I'm really new at JVM profiling and memory leak troubleshooting so I'm making certain assumptions and taking certain steps to feel my way through the process.


TOOLS
I'm using a combination of tools and OS logging to get feedback from the JVM.

1. YourKit for Java (http://www.yourkit.com/)
YourKit is very easy to install against a WebLogic JVM and monitor via a remote PC desktop. It is free for developers contributing to non-commercial Open Source projects, with an established and active community and has a reasonable academic license fee. YourKit has a script that will generate the modifications needed to be made to the host JVM. This makes installation much easier.

2. Sun's VisualVM I am evaluating this as I write. I see much of the features available in YourKit here, however YourKit has really easy setup and nicer charting features. VisualVm seems to beat JConsole pretty handily. To use VisualVM to retrieve data from a remote application, the jstatd utility needs to be running on the remote JVM. All the tools need some kind of modification to either the remote server or remote JVM startup parameters.

Some of the blogs about VisualVm have yielded a few really handy commands, such as jps (find the PID of the Java Processes) and jstat (get status of JVM at PID). I also see mention of something from Sun called visualgc which is also available from Sun's dev.java.net. Some of these appear possibly to be orphan projects.

3. Java's JConsole (http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html)
Jconsole provides basic information about a profiled JVM (not as much and not presented as nicely as YourKit, but it is free) and requires more setup (see my post "Connecting to a Remote JConsole Session" for setup.

4. A series of custom logging scripts that essentially scrape Unix top or other unix admin commands for pulling out information about the running processes and logging that information to a format that can be easily put into Excel for charting and analysis.


Links:
http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp
http://www.slideshare.net/kensipe/debugging-your-production-jvm
https://visualvm.dev.java.net/

No comments:

Post a Comment

Followers