Draw the heap dump's references as an expandable graph - #2932
Open
pyricau wants to merge 1 commit into
Open
Conversation
The three shapes so far all divide an area between the nodes of the dominator tree, which says how much an object retains but never which field holds it. This adds a fourth: circles joined by arrows, expanded outwards a click at a time from the node the view is rooted at, the way Xcode's memory graph is read. Arrows carry the field name, dominator edges are ringed, and the view pans and zooms rather than fitting the window, since what is drawn is what was asked for rather than a cut of the tree. The style is shared with the chain pane rather than copied: PathStyle.kt is the circle, the badge letter, the ring, the connector colours, the weak-reference dash and the arrow head, drawn by both PathDrawing and GraphView, so a change to either picture is a change to both. What is drawn lives in ObjectGraph, grown by one read of the heap dump per circle expanded, and GraphLayout arranges it — both in core, both unit tested. Arranging happens in composition rather than on the heap dump's thread, because it reads nothing, which is what makes expanding a circle instant instead of a spinner. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A fourth shape in Shark Explorer, next to the treemap, the rings and the stack.
The three shapes so far all divide an area between the nodes of the dominator tree. They say how much
an object retains and what it sits inside, and they can never say which field holds it, or whether
anything else does — that is the heap dump's own references, which the tree is a summary of.
So this one draws the references: circles joined by arrows, expanded outwards a click at a time from
the node the view is rooted at, the way Xcode's memory graph is read.
expanded, so a click that re-rooted the window would throw that away every time. Pressing a circle
opens it, pressing it again closes it — and closing keeps what was read, so opening it again reads
nothing. Going somewhere is still a click in the panels beside the view, as on every other screen.
edge is ringed: how an object is reached, and whether that is why it is alive, on one picture.
than a cut of the tree — and expanding never moves what is already on screen.
"leftovers" cell the other shapes already use for children they didn't draw.
children, so the shape opens where every other one does and the references start one click in. One
code path, no mode flag.
The drawing style is shared, not copied.
PathStyle.ktis the circle, the badge letter, the ring,the connector colours, the weak-reference dash and the arrow head; both the chain pane (
PathDrawing,a column joined top to bottom) and the graph (
GraphView, joined left to right) draw through it, so acolour or a radius changed in one place changes both pictures. The reference-naming is shared the same
way, down in
HeapDominatorTreemap.Where the work happens.
ObjectGraph(what has been expanded, and what each circle references,grown by one heap dump read per circle) and
GraphLayout(arranging it into columns and rows) are bothin
shark-explorer-coreand unit tested there. Arranging happens in composition rather than on theheap dump's thread, because it reads nothing — which is what makes expanding a circle instant rather
than a spinner, and what
TreeLayoutTestholds it to: switching to this shape lays the tree out nofurther.
Tests:
ObjectGraphTest,GraphLayoutTest,ObjectGraphReadingTest(core),GraphTransformTest,GraphViewTest(app).notes/treemap-rendering.mdandnotes/decisions.mdsay why it is shaped thisway.
🤖 Generated with Claude Code