Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify holder of reference to object in Java Memory Analyzer using heap dump

As i have some problems with OutOfMemoryErrors with an application i want to identify the root cause. This i created a heap dump (PHD) from the IBM VM on the AIX server and tried to analyze it using IBM Support assistant 4.1 and its Memory Analyzer tool.

When the heap dump is parsed ISA asks me if i want to run the leak suspect report.

Using the leak respect support i got the information about some classes which consume considerable amount of memory.

What i now want to identify is the holder of the object references, but i can e.g. only see what objects a ArrayList contains, but not who holds a reference to that ArrayList.

How can i get to that information?

like image 226
Joysn Avatar asked Jul 22 '14 12:07

Joysn


People also ask

How do you analyze a heap dump in Java?

Eclipse Memory Analyzer Tool ( MAT ) is used for analyzing heap dump files which contain objects in memory. Each heap dump file can be thought of as a snapshot in time and details the memory occupied by specific JVM threads.

How do I view Heapdump files?

Open Eclipse MAT To open the heapdump, go to File > Open Heap Dump (Not Acquire Heap Dump) and browse to your heapdump location.

How do I Analyse a heap dump in eclipse?

Use the Eclipse Memory Analyzer You may need to refresh your project (F5 on the project). Double-click the file and select the Leak Suspects Report. The overview page allows you to start the analysis of the heap dump. The dominator tree gives quickly an overview of the used objects.


1 Answers

Load you heap Dump in Memory Analyzer (MAT).

enter image description here Go to Histogram and see the big size Object.

enter image description here Now right click on this and select Immediate dominators. It will open a dominator tree and u can identify what is holding your object.

enter image description here

Sometimes when the big size object is local variable you will not be able to see immediate dominators in tree. It can only tell you that your variable is part of which thread.(Below image doesn't show this local variable scenario)

enter image description here

In that case check (stack trace ) where are you getting OutOfMemoryError. Then accordingly trace it backwards and try to find out in which method are you creating big size objects as local variables. Most of the cases we get big size objects in same method which is shown in stack trace as at some point of time while allocating more memory we get OutOfMemoryError.

More details.

like image 144
Vipin Avatar answered Nov 01 '22 11:11

Vipin