Skip to main content

Java SE 6 Monitoring, Management, Diagnosability

Posted by mandychung on December 11, 2006 at 3:40 AM PST

Java SE 6 final release is now available! My colleagues and I have blogged about Java SE 6 monitoring, management and diagnosability features in the past 1-2 years.
This presents an overview of the monitoring, management, and diagnosability features in Java SE 6 and also serves as a starting point for you to find the relevant blogs/articles/documentation. Enjoy!

Feature Brief Description Blogs/Articles
Dynamic Attach Capability With JDK 6, you no longer require to start your application with any special option to be attached by JDK 6 tools. The Attach API enables you to build your own tool to attach to a running JVM and load a Java or native agent.
Heap Dump and Analysis JDK 6 significantly enhances the ability of diagnosing memory problem. The HotSpot VM provides the ability to request a heap dump on demand from the jmap tool as well as programmatically. A heap analysis tool (jhat) is added in JDK 6 to browse the heap dump snapshot you obtain (see below for details).
OutOfMemoryError Diagnosability JDK 6 provides a better support to diagnose OutOfMemoryError. This error now includes a stack trace where the allocation failed. Another useful improvement is the -XX:+HeapDumpOnOutOfMemoryError option which tells the HotSpot VM to generate a heap dump when an allocation from the java heap or the permanent generation cannot be satisfied. In addition, a new -XX:OnOutOfMemoryError=<command> option is added for you to specify a command that the HotSpot VM will invoke when the OutOfMemoryError is thrown.
DTrace on Solaris JDK 6 HotSpot VM provides the built-in dtrace probes. You can now use dtrace to trace the whole stack of any running Java application on Solaris 10. JDK 6 comes with the sample DTrace scripts for you to start with (under the <Solaris JDK6>/sample/dtrace directory).
Troubleshooting Guide Java SE Troubleshooting Guide, a very popular and useful documentation , has been updated to include troubleshooting information for JDK 6.
JDK Monitoring and Troubleshooting Tools
jconsole The major JConsole enhancements include dynamic attach capability, the plugin API support and various UI improvement.

JConsole can attach to any running application which does not need to start with -Dcom.sun.management.jmxremote option. The new JConsole plugin API enables you to extend JConsole to add your own tab or custom UI for the application MBeans.

jhat A heap analysis tool, formerly HAT, is added in JDK 6 to browse a heap dump snapshot. It provides built-in queries to examine classes, instances, root set, heap histogram and objects pending for finalization. It also supports a built-in query language, OQL, to query the heap which is particular useful when searching on large number of objects.
jmap The jmap -dump and -histo options are now supported on Windows. It provides a light weight mechanism to obtain a heap histogram and heap snapshot on all platforms.
jstack The jstack tool is now supported on Windows. You can print Java stack traces and also detect deadlocks on all platforms. You can also use the new jstack -l option to print the list of owned java.util.concurrent locks.
jinfo The jinfo tool adds a new -flag option to get and set an VM option. For example you can use jinfo to set HeapDumpOnOutOfMemoryError at runtime.
API Enhancements
Java Management Extensions (JMX) The important features of the JMX API in JDK 6 are MXBeans and Descriptors. MXBeans enable bundling of related values in a MBean without requiring special client configurations to handle to bundle. Descriptors provide you a convenient way to attach additional metadata to your MBeans.
java.lang.management The java.lang.management API has been enhanced for monitors and java.util.concurrent locks monitoring. You can find the list of locks owned by a thread and also report which stack frame locked a monitor. It also provides a new method to obtain the system load average. In addition, a new HotSpotDiagnosticMXBean API provides the programmatic interface to obtain a heap dump and set a VM option.
java.lang.instrument The java.lang.instrument API has been enhanced to provide support for dynamic transformation of loaded classes, multiple agents and appending to class loader search.
JVM Tool Interface JVM TI has been enhanced to provide multiple agents support, better dynamic instrumentation, enhanced heap walking API, resource exhaustion notification, support for early return and monitor stack depth.
Java Platform Debugger Architecture (JPDA) JPDA has been enhanced to support heap walking functionality, force early return, view method arguments when not compiled with -g, process attach connector, monitor stack depth, and breakpoint on monitor locks/release.

Additional References:

1. Article: Monitoring and Managing Java SE 6 Platform Applications

2. Crash Course: Java SE Monitoring, Management and Troubleshooting

3. Java SE 6 Observability and Solaris OS

Related Topics >>