How to analyse heap dump
I have already
discussed about heap dump in one of the post.
Please refer the
link below to read it:
Now we will see
about how to analyze them. There are various tools for reading heap dump. I prefer
MAT (Eclipse Memory Analyzer Tool). It is powerful and free tool which can
read, parse and analyze them.
Before opening
heap dump in MAT, let’s focus on some basic things related to it:
-
Shallow Size: The sum of the sizes of all contained primitive data
types, as well as the size of the references to other objects
-
Retained Heap : The total size of all objects being kept
alive by this dominator
What MAT will do
with heap dump? It will parse the heap dump and it will appear as below in tree
format:
- char[]
- java.lang.Object[]
- java.lang.Class
- java.lang.String
- byte[]
- java.util.HashMap
- java.util.HashMap$Entry
- short[]
- int[]
- java.util.ArrayList
- java.lang.Integer
Then it will calculate retained Heap of objects
and display a pie graph which will show which objects as biggest size in term
of Retained Heap. Now to find structure or creation of these objects, we need
to look into incoming reference (reference to keep objects alive and prevent
them to into garbage collector) and outgoing reference (reference which shows actual
contents of the instances) of these objects.
To get them,
choose List Objects with incoming References from the context menu. It will display tree structure
of incoming reference. These references give us idea about objects which are
high of retained heap memory.
MAT also allows
comparing two heap dump snapshots and finding growing structures and instance
counts of two well timed dumps (some amount of load they should be minutes
apart, with few load hours or days.).
This way we can
find memory leak issues and related objects too.
You can also
refer the below link for MAT Knowledge:
very informative post for me as I am always looking for new content that can help me and my knowledge grow better.
ReplyDelete