Reference: Http://xmlandmore.blogspot.hk/2014/01/eclipse-mat-understand-incoming-and.html?utm_source=tuicool&utm_ Medium=referral
Saturday, January 25, 2014
Eclipse Mat:understand Incoming and outgoing References
In [1], we had shown how to use OQL to query String instances starting with a specified substring (i.e. , our objects of interest) from a heap dump. [7,8] To determine who's creating these objects, or find out what the purpose of some structures was, an object ' s Inc Oming and outgoing references become handy.
In this article, we'll examine the following topics:
- What is incoming references or outgoing references of an object?
Then look at both topics related to
Incoming References:
- Path to GC Roots
- Immediate Dominators
Outgoing References
Using the following OQL statement, we have identified total 7 entries (see figure above) as our objects of Intere St:
SELECT * from java.lang.String WHERE toString (). StartsWith ("http://xmlns.oracle.com/apps/fnd/applcore/log/ Service/types ")
After expanding the first entry, it shows
Outgoing References:
- A reference to the Class instance for the String object
- A reference to an array of char values
Outgoing ReferencesShow the actual contents of the instances, helping to find out their purpose. In our
Stringinstance, it holds the references. The memory overhead of this
StringInstance is shown in both values: [3]
- Shallow Heap
- Retained Heap
These sizes of String instances depends on the internal implementation of the JVM. Read [2,4] for more details. Incoming References
To get incoming references of the first entry, choose List Objects with incoming references fro M the context menu.
Now a tree structure are displayed, showing all instances with all incoming references (note the different icon hi Ghlighted in red). These references has kept the object alive and prevented it from being garbage collected.
Immediate Dominators
Similarly, from the context menu, you can display immediate dominators of the first entry (see figure below). An object X was said to dominate a object y if every path from the GC Root to Y must p The through X. So, the immediate Dominators is a very effective a-to-find out who is keeping a set of objects alive. For example, the immediate dominators of our first entry (note so we have used "java.*|com\.sun\. *' As our filter ' is:
- Oracle.j2ee.ws.server.deployment.WebServiceEndpoint
Path to GC Roots
From context menu, you can also show 'Path to GC Roots' of the first entry (see figure below). path to GC Roots shows the path to GC Roots which should is found for a given object. As can expect, its immediate dominators must also is on the this path. Note that if you display the Path to GC Roots, you can specify which the fields of the certain classes to being ignored when Finding paths. For example, we had specified that paths through Weak or Soft Reference referents to be excluded.
Live Data Set
Now we know
- Oracle.j2ee.ws.server.deployment.WebServiceEndpoint
is keeping our
StringInstance alive. Instead of viewing
Path to GC Roots, it's easier to see it's the other around. We have chosen to display the
Outgoing ReferencesOf
Webserviceendpointinstance (see figure below). As can see, our
StringInstance is displayed as the leaf node of the tree structure.
References
- Eclipse mat:querying Heap Objects Using OQL (Xml and more)
- Java memory usage of simple data structure
- Shallow vs. retained Heap
- Create and understand Java Heapdumps (Act 4)
- Diagnosing Java.lang.OutOfMemoryError (XML and more)
- I Bet you had a Memory Leak in Your application by Nikita Salnikov-tarnovski
- Classloader leak is the most common leak in Web applications
- How to analyze heap dumps
- Leak can induced
- Per call (or a class of objects)
- Per Object
- Diagnosing Heap Stress in HotSpot (XML and more)
Posted by XML and more at 10:45 AM
Eclipse Mat:understand Incoming and outgoing References