Heap Walker - Graph


  The heap walker graph does not automatically show any objects from the current object set, nor is it cleared when you change the current object set. You manually add selected objects to the graph in the outgoing references view, the incoming references view or the biggest objects view.

In the graph, you can explore the incoming and outgoing references of the selected objects and find paths between objects or paths to garbage collector roots.

  The graph has the following properties:
  • Instances are painted as rectangles with the class name of the instance written inside the rectangle.
  • References are painted as arrows, the arrowhead points from the holder toward the holdee. If you move the mouse over the reference, a tooltip window will be displayed that shows details for the particular reference.
  • Instances that were manually added from the reference views have a blue background. The more recently an instance has been added, the darker the background color.
  • Garbage collector roots have a red background.

    A garbage collector root is an entity in the JVM that itself is not garbage collected and pins other objects or classes. There are the following types of garbage collector roots:

    • JNI references
      Native code can request references from the JNI (local or global)
    • stack
      Local variables all current stack frames
    • sticky class
      The JVM itself can flag certain classes as non-garbage collectable
    • thread block
      Live threads are not garbage collected
    • monitor used
      A monitor that is held by someone cannot be garbage collected
    • other GC root
      The JVM can pin objects by attaching this unspecified GC root to them

    For classes there is a special condition that prevents garbage collection: Since each instance has an implicit reference to its class, any live instance prevents a class from being garbage collected. This construct groups all such instances for reasons of conciseness. In this way you can also select all instances of a specific class (rather than a specific class name).

    A set of live instances that reference a yellow class object (see above) has a green background.

  • Classes (objects of java.lang.Class) have a yellow background.

    In most circumstances, classes are the last step on the path to the GC root that you are interested in. Classes are not garbage collector roots, but in all situations where no custom classloaders are used it is appropriate and easier to treat them as such. This is JProfiler's default mode when searching for garbage collector roots, you can change this in the path to root options dialog.

    Class objects have references to

    • all implemented interfaces
    • their classloader unless they were loaded by the bootstrap classloader
    • all references in their constant pool

    Note that class objects have no reference to their super class.

    Classes are garbage collected together with their classloader when

    • there is no class loaded by that classloader that has any live instances
    • the classloader is unreferenced except by its classes (this is a JVM level reference and not visible in the source of java.lang.Class).
    • None of the java.lang.Class objects is referenced except by the classloader and other classes of that classloader.

  • String values are shown directly in the java.lang.String instance rectangle.
By default, the reference graph only shows the direct incoming and outgoing references of the current instance. You can expand the graph by double clicking on any object. This will expand either the direct incoming or the outgoing references for that object, depending on the direction you're moving in. Selective actions for expanding the graph are available in the view-specific toolbar and the context menu:
  •  Show outgoing references
  •  Show incoming references

If applicable, an instance has plus signs at the left and the right side to show or hide incoming and outgoing references. The controls at the left side are for incoming, the controls at the right side for outgoing references. The plus signs have the same effect as the  Show outgoing references and the  Show incoming references actions. If there is no plus sign, all references have been expanded.

Any modification to the reference graph can be reverted with the  undo action. If you open a large number of references and want to track back to a previous state of the graph, hit this button repeatedly. If you hit undo too may times, a  redo action is also available. Consecutive undo/redo is useful for replaying what happens to the graph when expanding a node.

Each object is optionally annotated with an object ID. With this ID, you can check whether two objects are the same or not. The display of IDs can be switched off the the context menu and the view settings.

  You can  hide nodes by selecting them and pressing the delete key. You can select multiple nodes by holding the with the CTRL or SHIFT key and delete them together.

The graph may contain a number of unconnected branches. To clean up the graph, select a node on the branch that should be retained and select the  remove unconnected items action from the graph toolbar or the context menu.

To remove all objects from the graph to its original state, you can choose Clear Graph from the context menu.

The reference graph offers a number of navigation and zoom options.

 

To check why an instance is not garbage collected, you can select it and click the  [Show paths to GC root] button at the top of the view. The options dialog allows you to configure the way JProfiler performs the search.

After the search has completed, the graph is expanded up to the garbage collector roots that were found. If the object is not referenced by a garbage collector root, a message box will be displayed. Note that this case is only possible if the "Perform full GC in heap dump" option in the heap walker option dialog is unchecked.

The garbage collector roots themselves are displayed with a red background.
  Another kind of path that can be interesting is the path between two selected objects. The  [Find path between two selected nodes] button at the top of the graph becomes active once you select exactly two nodes in the graph. The path search options dialog allows you to select the type of the path and the stopping points of the search.

Any found path will be highlighted in red along the edges of the path. When you search for another path, the old highlighted path displayed in black again.

  There are four layout strategies for showing the reference graph which can be chosen by clicking on in the toolbar or choosing the layout strategy from the context menu.
  • Hierarchic layout
    Standard layout that tries to layout the graph from left to right. This is suitable for most purposes.
  • Hierarchic layout (Top to Bottom)
    Like above, only that the layout axis is vertical. This can be suitable for viewing long chains of references.
  • Organic layout
    Layout that tries to layout instances for optimal proximity. This layout is suitable for complex situations and can visualize clusters.
  • Orthogonal layout
    Layout that tries to layout instances on a rectangular grid. This layout is suitable if your objects form a matrix.
  To add a selection step from this view you can select one or multiple objects and click the [Use ...] button above the graph and choose in the popup menu. Multiple objects are selected by keeping the SHIFT or CTRL keys pressed during selection. The following selection modes are available:
  • Selected Objects
    A new object set will be created that contains only the selected instances.
  • Selected java.lang.Class Objects
    The new object set will consist of all java.lang.Class objects of the selected instances.
  • Items in Selected Collection
    This option is only enabled if you select an array of objects or a standard collection from the java.util package. A new object set will be created that contains the objects in the array or collection. If you select a map collection, you are prompted whether you want to include the key objects as well.
  • Loaded Instances By Selected Class Loader
    This option is only enabled if you select one or more instances of java.lang.ClassLoader. A new object set will be created that contains the objects whose classes have been loaded by the selected class loaders.
  • Retained Objects
    A new object set will be created that contains all objects that would be garbage collected if the selected objects did not exist on the heap. This always includes the selected objects.

After your selection, the view helper dialog will assist you in choosing the appropriate view for the new object set.