Exploring Memory Analysis Views > Exploring the Leak Doctor View > Understanding the Leak Doctor
The purpose of the Leak Doctor is to model what would happen if you removed a reference. You can show more nodes, show fewer nodes, and redraw the graph. After removing references, you can restore them if you like.
The Leak Doctor starts at the loiterer and traces the paths back through instances that reference the loitering object, using a “breadth first” algorithm. In other words, it looks at all the children of a referrer for objects of interest before moving on to its grandchildren. The search stops when a referrer is discovered that has a comment. The comments are explained in the following table.
A number of instances in the heap will be pinned by roots; the different types are described below.
• JNI Global Roots happen when native code creates a global reference to an instance.
• JNI Local Roots happen when native code is called with instances in the heap.
• Stack Local Roots happen when a method is invoked; they pin the local variables of the method.
• Sticky/System Class Roots happen for a number of classes in the system that the VM does not want to go away.
• Monitor Roots happen when something acquires a lock.
• Thread Roots exist for each thread running in the system.
• Other (not in any of the above categories)
When you select a reference in the upper panel and
click the Remove Edge toolbar button,
the reference is removed from the heap and added to the table to the
lower pane. If removing this reference will free the loitering object,
the following message appears:
You now know that you can remove this reference from your code.
A different message may appear that indicates that no paths to a root were found for this instance. This can be due to a number of reasons, but does not guarantee that this instance is not being held. You may want to investigate further on your own to see if this instance is contributing to the memory problem.
If you have removed multiple references from the
graph, it may be good to restore some of them to find the minimal number
that are required to free the loiterer. You can restore a reference
by selecting it in the lower pane and clicking the Restore Edge toolbar button.