|
|
This section gives a brief look at the Reference Pattern view. Its forte is summarizing references among objects. It's especially useful for exploring data structures and finding memory leaks, which can occur even in a garbage-collected environment like Java's.
| To start Jinsight with the RPExample1 trace: |
|
Load the whole trace before viewing it. That will
let the Reference Pattern view read
the object reference information at the end of the trace.
| To load the trace: |
|
The view comes up blank initially. The first thing to do is to choose
a base set of objects to explore. Let's limit our our base
set to objects in application code, as opposed to library code. Specifically,
we will omit objects from the JDK, which tend to be plentiful but less
interesting than objects you've programmed yourself.
| To show all non-JDK (and non-array) objects: |
|
Squares in the view represent either a single instance of a given type (if it's a single square) or multiple instances (represented by twin squares). Diamonds represent class objects. Objects are colored uniquely by type as in the Execution and Execution Pattern views. The precise number of objects and their type appears to the immediate right of a square or diamond. Objects in the gray area make up the base set from which to explore references. Arrows between objects represent references. An arrowhead points to the object being referenced.

| To turn sorting off: |
|
Now scroll down to the bottom of the view. Your view should look like this:

Above these class objects is an orange square-and-diamond
combination representing three objects related to the ShadowFramer class:
one is the class object, and the remaining two are regular instances. Farther
to the right are several objects—some you may have to scroll to see—that
refer to one or more of the ShadowFramer objects. But even if you scroll
or resize the view window, you still can't see everything. It's not
clear who refers to whom, because you can't currently see the ShadowFramer
objects individually. To do that, you ungroup the orange diamond-square.
| To ungroup the ShadowFramer objects: |
|
Note the blue upward arrow annotated "backpointer" (on the right) in the figure above.
The blue arrow calls attention to the fact that this instance of ShadowFramer is actually
a reappearance of the ShadowFramer instance above it in the tree.
Thus in this case we see a circular reference: the first ShadowFramer instance refers
to the LightweightDispatcher, and vice versa. A blue arrow accompanies
repeat appearances of objects to help you find the original appearance.
| To locate the original ShadowFramer square: |
|
The blue arrow now extends to the original orange ShadowFramer square. (Left-click again at the base of the blue arrow to remove it.)
Not all references are shown in the view. Squares with a "+" appearing
in a box to their left have hidden references to/from them.
| To see hidden references: |
|
The tree of references will expand to show the hidden references to/from
this object(s).
| To expand all squares at a given depth in the tree: |
|
Note that reference arrows are drawn right-to-left by default.
| To see the references drawn in the opposite direction (left-to-right): |
|
| To return to the default direction: |
|
Use these navigation mechanisms to explore the space of references and to study data structures such as trees and linked lists.
| To find the anchors: |
|
RPExample1.trc is in fact a trace that helped us find a memory leak in Jinsight itself. Jinsight's performance degraded noticeably after using many views on a large execution, even though we never had more than a few views open at a time. Now we'll use the Reference Pattern view to track down the leak (we needn't rerun the trace).
Since we're looking for references to new generation objects from the
old generation, we tell the view to start with new generation objects.
In particular, we will first focus on objects of user-defined classes that aren't being
collected. Solving a memory leak in one of these classes often will allow
lower-level objects, such as JDK objects and arrays, to be released.
| To start with a base set of application objects: |
|
Note the base set. It contains all the new-generation application objects (including class objects but not arrays). Either old- or new-generation objects can appear outside the base set; new-generation objects outside the base set are repeat appearances.
In this trace, the new-generation objects were created when we opened
and immediately closed an Execution view
in the leaky version of Jinsight. The text in the upper left of the base
set area indicates that there are 34 new-generation objects. Most
if not all of these objects should eventually get collected—assuming no
anchor objects from the old generation still refer to them.
| To single out the anchors: |
|
Now references in the view are expanded only enough to see those from old-generation objects. Scrolling down, you will see there's only one reference from an old-generation object. It's easy to see because its name appears in red:

|
|