How to dump JVM IBM heap and open it for analysis in MAT

Most of the clients I’m working with are using SUN JVM. However some of them are using IBM VM. As you know, even if the same code can be launched on both many things vary from the one to another, VM options, Garbage collection tuning etc…

I worked recently on solving a memory leak issue and I’ve been confronted to the following straightforward problem: How to be able to get a heap dump that I can analyse with the tools I know well, and that I consider as the best in Open-Source tools. For dump analysis I’m referring to MAT (Memory Analyser Tool from SAP hosted by Eclipse foundation).

First Step: How to get a dump

The best way to get a dump for analysis with IBM VM is in fact not to get a « heap dump » but a « system dump ». This is a particularity from IBM VM. Basically a heap dump will not allow you to access fields names and values in the analysis step (using MAT). This means that you will not be able to benefits from the power of OQL queries.

In order to get a dump use the following options:

-Xdump:system:events=user,request=exclusive+prepwalk

You can now export a system dump by launching a kill signal to the application (kill -3 under linux/unix).

I also encourage you to use dumping on OutOfMemory error that is very useful in most of scenario!

-Xdump:system:events=systhrow,filter=java/lang/OutOfMemoryError,request=exclusive+prepwalk

Note that the -Xdump is very powerfull and you can really customize the option to launch a dump on almost any event in your application. Read more here http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/index.jsp?topic=/com.ibm.java.doc.diagnostics.60/html/dumpagents_syntax.html.
System dumps will produce a file named core.(date).(time).(process id).dmp

This file will not be usable as it is for analysis, you must first transform it using the IBM JVM jextract command on it. This will generate a zip file that you’ll be able to process.

Open the dump in MAT for analysis

Now you can import the zip file generated from the first step into MAT and analyse your dump!

I hope this article will help you if you work with IBM VM and solve memory issues some day.