How to analyse Heap dumps using Eclipse MAT

We have seen in previous article about how to generate Heap dumps. Once we have heap dump, we need analyse them to find out possible cause of OOME. Let’s see how to analyse Heap dumps using Eclipse MAT

For this we would need a Heap dump. Let’s create a simple program that generates Heap dump

OOME generating Program

The program is simple, we just keep on adding data to an in-memory hashmap. Let’s quickly see the code

Next we run it with command line option to generate Heap Dump when it goes out of Memory. Details covered here

Once you run the program, you would see something like this

Getting Eclipse MAT

You would need Eclipse MAT to be installed on Eclipse. More details here

Analyse Heap dump in Eclipse MAT

Launch Eclipse and open the Window > Open Perspective > Memory Analysis

Click on Open Heap dump

Open Heap dump

Open Heap dump

Eclipse MAT would parse the Heap dump and open a UI shown in image below (UI prompts for selecting an option, choose Leak suspect report)


Once done, the UI shall show possible leak suspects


Here it shows that Hashmap is the causing the OOME. This case is simple, but many times you would need to dig deeper trying to figure out what actually is taking the memory. If we need to dig deeper and try to find out the content of Hashmap, we would use “Open Dominator tree for entire heap” option from the tool bar


This would open a UI with all the heap contents shown as tree


Using the UI, we can browse the heap content and find out what is causing the memory pressure. This shall provide pointers to further course of action like tuning heap settings or optimising Application.

Leave a Reply

Your email address will not be published. Required fields are marked *