Skip to content

Print path to GC root on leak (no VisualVM needed)#11

Closed
FlorianKirmaier wants to merge 1 commit into
masterfrom
print-path-to-gc-root
Closed

Print path to GC root on leak (no VisualVM needed)#11
FlorianKirmaier wants to merge 1 commit into
masterfrom
print-path-to-gc-root

Conversation

@FlorianKirmaier

Copy link
Copy Markdown
Contributor

On a failed leak check, JMemoryBuddy now reads back the heap dump it already writes and prints the strong-reference path from a GC root to each not-collected object — so the common case no longer needs VisualVM/MAT.

  • Dependency-free, self-contained HPROF reader (keeps the library minimal-dependency).
  • Targets located via a marker TrackedWeakReference; Reference.referent is excluded so weak refs never appear as the retaining path.
  • Best-effort: falls back silently (dump still written) on parse issues or heaps larger than -Djmemorybuddy.maxObjects. Disable with -Djmemorybuddy.printPath=false.

Example:

GC root [Java frame] Holder
  ↓ Holder.field
Object   ← leaked

🤖 Generated with Claude Code

On a failed leak check, read back the heap dump JMemoryBuddy already creates and
print the strong-reference path from a GC root to each not-collected object.
Targets are located via a marker TrackedWeakReference; weak referents are excluded
from the path. Best-effort, off with -Djmemorybuddy.printPath=false.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@FlorianKirmaier FlorianKirmaier deleted the print-path-to-gc-root branch June 14, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant