BenComan / PointerDetective
About PointerDetective
Whats it for
Do you find it hard to discover why objects aren't being garbage collected?
It can be hard using the tree list of the standard Pointer Explorer, especially when there are reference loops. This is easier when visualised as directed graph. Pointer Detective provides a directed graph to visualise references between objects. The graph incrementally builds out from the target object as you investigate. Nodes are colourised to help manage complexity. It is invoked like this...
PointerDetective openOn: targetObject.
That opens a window with a single node shown for the target object. Thereafter you can...
Hover over a node to get a tool-tip showing the wrapped object.
Double-click...
On a leaf node to show its 'pointersTo'. Leaf nodes are indicated by a thick border.
On the background to show the 'pointersTo' all current leaf nodes.
Drag nodes to arrange into custom layout.
Hold mouse down...
On a stationary node, to adjust layout by pulling attached nodes closer:
with control key pressed, affects just one layer.
with shift key pressed, affects multiple layers.
On the background to auto adjust layout:
- with optional control key pressed, uses a spring-force layout.
For example
Evaluating the following in a Workspace...
testObject := 'END5'.
ref1 := { testObject. nil }.
ref2 := { ref1 }.
ref3 := PDTestResource new heldObject: ref2.
ref1 at: 2 put: ref3. "note the reference loop this creates"
PointerDetective openOn: testObject.
allows you to discover this...
Note: The labels are momentary popups, compiled here into one image for demonstration only.
Legend:
Green - Target Object.
Light Green - Morphs.
White - Collections.
Brown - Workspace.
Yellow - Other.
Status
Version.1 is working well enough for my needs. It is shared here in the hope that its useful to others. For now I am avoiding the drain of making it perfect, pending feedback from any users. However I desire no great sense of ownership. It was just a momentary itch I had to scratch. Feel free to lead it in any direction you require. Its a public repository. I'll be glad to assist where needed.
Some areas that could be improved:
The standard layout is a bit naive (not my area of expertise). After a few attempts, it was just the simplest thing I could do. It could do with some care from someone with good layout-fu.
The force layout can be slow with large numbers of nodes. Might be useful to run it as a background priority task, and/or provide a progress bar.
Leaf nodes might be sorted to detangle them a bit.
A node menu would be useful, with at least items 'Inspect' and 'Pointer Explorer'
Node annotation, with the option to be permanently display for selected nodes (rather than just as tool tips).
Allow colourisation conditions to be configurable in a UI panel to the side of the graph (rather than just in code (see PDNode>>applyColor))
PDRTxxxx classes need to be cleaned up. These classes are mostly intact as copied from Roassal, and some methods may be superfluous away from that context.
Needs a Configuration for the meta-repo, to be visible in the Configuration Browser.
Define some tests and a CI job.
Allow candidate from-objects to be user filtered.
Start from a collection of nodes, rather than just one.
Auto-find path to the GC root.
Maybe PDNode>>wrappedObject: can use some kind of 'weak slot' rather than wrapping objects with a WeakArray.
Compatibility
Pointer Detective only uses core Morphic classes (EllipseMorph, PolygonMorph & BorderedMorph) so hopefully it is widely compatible. Please advise if you find it works on other platforms so I can list them here (or even just where you would like it working).
- Pharo 4.0 alpha (build 40171) - used for initial development.
- Pharo 3.0 (build 30856) - cursory testing successful.
- Squeak 4.5 - cursory testing works, except two actions requiring control key modifier causes a menu to appear instead. (Version.3 works with compatibility package PointerDetective-Squeak45Platform. This is my very first attempt at cross platform, so I'd be happy for advice (if indeed any Squeakers find the tool useful) ).
