Using the Eclipse Memory Analyzer (MAT) Remotely on Large Heap Dumps

Sometime your java applilcation will fail and generate an enormous heap dump.  One that may be too large to be able to transfer to your local machine and to analyze for lack of RAM, time or both.

One solution is to install the MAT tool on the remote server and generate an HTML output of the analysis to download and view locally.  This saves the headache of attempting to get X Windows installed on the remote machine and get all of the ssh tunneling sorted out (which is of course an option as well).

First, download and install the stand-alone Eclipse RCP Application.  Then transfer to your server and unpack.  Then determine how large the heap dump is and, if necessary, modify the MemoryAnalyzer.ini file to instantiate a JVM with enough RAM for your heap dump.

In this example, I have an 11GB heap dump and have modified the last two lines (adding -Xms)

-startup
plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.300.v20150602-1417
-vmargs
-Xmx16g
-Xms16g

Do an initial run to parse the heap dump.  This will generate intermediary data that can be used by subsequent runs to make future analysis faster.

./ParseHeapDump.sh /path/to/heap-dump

After that completes, you can run any of a number of different analysis on the data.  The following is an illustration of how to search for memory leak suspects.

./ParseHeapDump.sh /path/to/heap-dump org.eclipse.mat.api:suspects

Additional reports:

org.eclipse.mat.api:suspects
org.eclipse.mat.api:overview
org.eclipse.mat.api:top_components

To give creadit where it is due, this is basically a copy of a post by Ashwin Jayaprakash, but I wanted to capture it here as well.

Leave a Reply