One of the key feature of Memory Analyzer is the leak suspects view. Memory Analyzer has capabilities to find the leaksuspects, large tress / deeply nested trees that contribute for large java heap usage.
How MAT suspects something as leaking?
To undertand this we need to get familiar two terms
1. Shallow size of the object
2.Retained size of the object.
Shallow size is the size of the individual object alone whereas Retained size is the total size of the object tree which includes its children (objects referenced by this object) also. Consider A is the root object and it has outgoing references to B and C (which are chil-dren of A). B has incoming reference to A and outgoing references to B1 and B2. Here the size of object A is 100 which is called Shallow size and Total tree size of A is 140 which is called Re-tained size as it includes the size of its children. Consider the size of B1 as 1000 and the total size of A is 1135. Here A is biggest consumer tree and in that B1 is the suspect because it is the biggest consuming child in the A tree.
A significant drop in the retained sizes shows the accumulation point and we can view the chain of objects and references which keep the suspect alive. The largest drop in the total size in the retained sizes helps to provide a relatively analysis to find the leak suspects. A significant drop in the retained size can be due to very large objects in the subtree or too many accumulated objects for example: collections
Memory Analyzer parses the dumpfile (heapdump or the processes system dumps), it compares the shallow and retained size of the objects in the tree and gives you the leak suspect report. This view is the default report generated by the Memory Analyzer . The tool has the in-built capabilities to look for probable leak suspects, large objects or collections of objects that contribute significantly to the Java heap usage and displays this information in the form of a pie chart. This reports memory leak suspects and checks for known anti-patterns. Below the pie chart view we can find the information about the suspects, the objects’ memory utilization, number of instances, total memory usage, and owning class. From the same view we can do more interactive analysis of suspects provided by the memory analyzer.
One of the sample view from Memory leak report is