Friday Aug 15, 2008
Tuesday Jul 08, 2008
By Gregg Sporar on Jul 08, 2008
JDK 6 Update 7 has been released. You can download the bits here.
This is the first JDK update from Sun that includes the new Java VisualVM tool. Jarda and I talked about Java VisualVM at JavaOne this year during our presentation on monitoring/troubleshooting tools.
Well, Jarda did most of the talking - since he is actually working on the code he is the expert. :-)
In any event, Java VisualVM is a new GUI-based tool for troubleshooting Java applications. It incorporates technology from multiple projects, including among others, jstack, JMX, and the NetBeans profiling tools, in order to provide one easy-to-use visual diagnostic tool for both development and production environments.
To me, that phrase "incorporates technology from multiple projects" is one of the most important parts of the story. During our presentation, Jarda and I discussed twelve tools (the talk was broad, not deep). Dealing with that many tools can be a pain, which is why it is nice that Java VisualVM includes functionality from so many of the different tools.
The NetBeans IDE has had for many years some very powerful tools for profiling Java applications and now some of those tools are available outside of the IDE in Java VisualVM. The user interface for those profiling tools, however, is a bit different in Java Visual VM. This is not surprising, since Java VisualVM does not have access to the source code for the application when doing profiling.
For example, one of the standard demonstrations of the NetBeans profiling tools is to profile the Java2D application that is included in the JDK. The profiler supports the concept of "root methods" which are starting points for doing the bytecode instrumentation necessary for collecting CPU performance data. I typically choose all the methods in the java2d.demos.Colors.Rotator3D class. In the NetBeans IDE, the user interface is:
In Java VisualVM, however, you would instead use this portion of the profiler settings tab to type in the fully-qualified name of the class:
There are, of course, other differences as well. For more information on Java VisualVM check out this features page.
One last thing: the NetBeans profiling tools require calibration data. This data provides a baseline for the performance of the hardware that is being profiled. If it does not find any existing calibration data (it looks for a .nbprofiler subdirectory in your home directory), Java VisualVM calculates the calibration data on first startup:
After it finishes, it will display this dialog:
Note the warning about CPU frequency switching. If your system does dynamic CPU frequency switching, exit Java VisualVM, remove the .nbprofiler subdirectory and then restart Java VisualVM. For those of you running on OpenSolaris, check out this blog entry and specify disable instead of enable. Then do the calibration by restarting Java VisualVM. After the calibration is done, switch the cpupm entry back to enable and re-run the pmconfig command.