Overview
This example demonstrates using Claude Code to guide you through analyzing Java heap dumps (.hprof files) with local tools like Eclipse MAT and VisualVM.
Credit: Victor Rentea
The heap dump examples used in this demonstration are from Victor Rentea's excellent Java memory leak training materials. Victor presented at Devoxx Belgium on Monday and generously makes these educational resources available to the community.
What This Demonstrates
- Using Claude Code to interpret Eclipse MAT leak suspect reports
- Understanding object reference chains and retention paths
- Identifying common leak patterns (ThreadLocal, listeners, ClassLoaders)
- Writing OQL queries for heap dump analysis
- Troubleshooting OutOfMemoryErrors and memory leaks
Download CLAUDE.md
This CLAUDE.md guides Claude Code through heap dump analysis workflows.
Download heapdump-analysis.mdSample Prompts
Try these prompts with Claude Code when analyzing heap dumps:
Initial Analysis
I have a heap dump from a production OutOfMemoryError. Load it in Eclipse MAT and help me interpret the leak suspects report.
Thread Investigation
The MAT report shows 'Thread' objects consuming 2GB. Help me identify which threads are leaking and why they're not being garbage collected.
ThreadLocal Issues
I suspect a ThreadLocal leak in our application. Show me how to use MAT's OQL to find all ThreadLocal instances and their retained sizes.
Reference Chain Analysis
MAT shows this object reference chain (paste chain). Explain what's causing the leak and how to fix it.
Performance Tuning
Analyze this heap dump and suggest JVM tuning parameters. The application frequently triggers full GCs.
Common Memory Leak Patterns
Examples from Victor Rentea's collection:
ThreadLocal + Thread Pool
Symptom: Memory grows with each request as ThreadLocal values are never cleaned from thread pool threads.
Claude helps: Identify ThreadLocal instances, explain retention paths, suggest proper cleanup patterns.
ClassLoader Leaks
Symptom: Application redeploys cause memory growth as old classes can't be unloaded.
Claude helps: Find what's holding ClassLoader references, suggest proper shutdown procedures.
Listener/Observer Leaks
Symptom: Objects held by event dispatchers even after "removal" from application.
Claude helps: Trace listener collections, identify registration without deregistration.
Hidden Object Links
Symptom: Unexpected references preventing garbage collection (SubList, Iterator, etc.).
Claude helps: Explain non-obvious retention paths, suggest safer API usage.
Tools & Documentation
Victor Rentea's Materials
Heap dumps and training materials on Java memory leaks.
Download Heap Dumps →Java GC Tuning Guide
Official Oracle documentation on garbage collection and memory management.
GC Tuning →How Claude Code Helps
- 🔍 Interprets MAT Reports - Explains leak suspects in plain language
- 🔗 Explains Reference Chains - Traces why objects are retained
- 📊 Generates OQL Queries - Custom queries for your specific investigation
- 🎯 Identifies Patterns - Recognizes common leak scenarios
- 💡 Suggests Fixes - Actionable remediation steps
- ⚙️ JVM Tuning - Recommends flags for monitoring and troubleshooting