Debugging from dumps

Diagnose more than memory leaks with Memory Analyzer:

Snapshot dump types

Memory Analyzer can currently work with three dump types:

  • IBM Portable Heap Dump (PHD): This proprietary IBM format contains only the type and size of each Java object in the process, and the relationships among the objects. This dump-file format is significantly smaller than the other formats and contains the least information. The data is usually sufficient, though, for diagnosing memory leaks and getting a basic understanding of the application’s architecture and footprint.
  • HPROF binary dump: The HPROF binary format contains all the data present in the IBM PHD format as well as the primitive data held inside the Java objects, and the thread details. You can look at the values held in fields inside the objects and see which methods were being executed at the time the dump was taken. The additional primitive data makes HPROF dumps significantly larger than PHD-format dumps; they are approximately the same size as the used Java heap.
  • IBM system dumps: When the IBM Java runtime is being used, the native operating-system dump file — a core file on AIX® or Linux, a minidump on Windows®, or a SVC dump on z/OS®— can be loaded into Memory Analyzer. These dumps contain the entire memory image of the running application — all the information and data in the HPROF format, as well as all of the native-memory and thread information. This is the largest and most comprehensive dump-file format.

Both IBM dump types are available only with the Diagnostic Tool Framework for Java (DTFJ) plug-in installed (see Resources and the Memory Analyzer variants sidebar).

Table 1 summarises the differences among the dump-file types:

Table 1. Summary of the dump types’ characteristics
Dump format Approximate size on disk Objects, classes, and classloaders Thread details Field names Field and array references Primitive fields Primitive array contents Accurate garbage-collection roots Native memory and threads
IBM PHD 20 percent of Java heap size Y With Javacore* N Y N N N N
HPROF Java heap size Y Y Y Y Y Y Y N
IBM system dumps Java heap size + 30 percent Y Y Y Y Y Y Y Y

*By loading in both a javacore.txt file (IBM thread dump file) and a file that were generated at the same time, Memory Analyzer makes thread details available in the IBM PHD format dump.

Both the HPROF and IBM system dump formats can be compressed well, usually to around 20 percent of their original size, using operating-system tools.

Using the IBM dump engine: The dump engine provides a large number of events on which you can produce a PHD or system dump. Further, it lets you filter on types of those events in order to exercise finer-grained control over when to generate dumps.

You can see the default events by using the -Xdump:what option. You’ll notice, for example, that a and javacore.txt are produced on the first four OutOfMemoryError exceptions in the JVM.

  • Available dump events
    Event Description Available filtering Example
    gpf General protection fault (crash) -Xdump:system:events=gpf
    user User generated signal (SIGQUIT or Ctrl+Break) -Xdump:system:events=user
    vmstop VM shutdown, including call to System.exit() exit code -Xdump:system:events=vmstop,filter=#0..#10
    Generate a system dump on VM shutdown with an exit code between 0 and 10.
    load Class load Class name -Xdump:system:events=load,filter=com/ibm/example/Example
    Generate a system dump when the class is loaded.
    unload Class unload Class name -Xdump:system:events=unload,filter=com/ibm/example/Example
    Generate a system dump when the class is unloaded.
    throw An exception being thrown Exception class name -Xdump:system:events=throw,filter=java/net/ConnectException
    Generate a system dump when a ConnectException is generated.
    catch An exception being caught Exception class name -Xdump:system:events=catch,filter=java/net/ConnectException
    Generate a system dump when a ConnectException is caught.
    systhrow A Java exception is about to be thrown by the JVM. (This is different from the throw event because it is only triggered for error conditions detected internally in the JVM.) Exception class name -Xdump:system:events=systhrow,filter=java/lang/OutOfMemoryError
    Generate a system dump when an OutOfMemoryError is generated.
    allocation A Java object is allocated Size of object being allocated -Xdump:system:events=allocate,filter=#5m
    Generate a system dump when an object larger than 5MB is allocated.