eclipse-mat
Skill1 starsChanged 9 months agoMITView on GitHub
Analyze Java heap dumps using Eclipse Memory Analyzer Tool (MAT). Use when the user asks to analyze heap dumps, find memory leaks, inspect object retention, run OQL queries, or investigate OutOfMemoryError issues.
In this repositoryOne other file it gives its agents.
- memoSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 1 is distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 36
Run this first to confirm MAT and Java are available.
- Very specific: line 44
If the heap dump has been parsed before, MAT creates .index files next to it.
- Very specific: line 152
Healthcheck first: Run scripts/mat.sh healthcheck to verify the setup
- Very specific: line 153
Check index status: Run scripts/mat.sh index-status <heap> — if already indexed, subsequent operations will be faster
- Very specific: line 154
Start with overview: Run scripts/mat.sh report <heap> org.eclipse.mat.api:overview to get class histogram and system info
- Very specific: line 155
Run leak suspects: Run scripts/mat.sh report <heap> org.eclipse.mat.api:suspects for automatic leak detection
- Very specific: line 156
Drill down: Use scripts/mat.sh command <heap> histogram for class-level breakdown, then dominator_tree for retained size analysis
- Very specific: line 157
Investigate specific objects: Use scripts/mat.sh oql <heap> "SELECT ..." to inspect individual objects by address or class
- Very specific: line 158
Thread analysis: Use scripts/mat.sh command <heap> thread_overview to see thread stacks and local variables
- Very specific: line 172
Use --limit with OQL and commands to avoid overwhelming output
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MAT Heap Dump Analysis
Analyze Java heap dumps headlessly using Eclipse MAT via the scripts/mat.sh shell wrapper.
Prerequisites
- MAT installed at
/Applications/MemoryAnalyzer.app/Contents/Eclipse/(new) or/Applications/mat.app/Contents/Eclipse/(legacy), auto-detected in that order (or setMAT_HOME) - Java 17+ available via
$JAVA_HOME/bin/java,/usr/libexec/java_home -V, orjavaon PATH
Script Location
scripts/mat.sh in this skills folder.
Environment Variables
| Variable | Default | Description |
MAT_HOME | auto-detected (MemoryAnalyzer.app → mat.app) | MAT installation root |
MAT_XMX | 4g | Java max heap size for MAT |
MAT_TIMEOUT | 1800 | Command timeout in seconds |
JAVA_HOME | (system) | Java installation directory |
Operations
1. Healthcheck — Verify MAT + Java setup
scripts/mat.sh healthcheckRun this first to confirm MAT and Java are available.
2. Index Status — Check if a heap dump is already indexed
scripts/mat.sh index-status /path/to/dump.hprofIf the heap dump has been parsed before, MAT creates .index files next to it. This avoids re-indexing on subsequent operations.
3. Parse Report — Run predefined analysis reports
scripts/mat.sh report /path/to/dump.hprof <report_id> [options...]Available report IDs:
| Report ID | Description |
org.eclipse.mat.api:suspects | Leak suspects report — identifies likely memory leaks |
org.eclipse.mat.api:overview | Heap overview — class histogram, top consumers, system info |
org.eclipse.mat.api:top_components | Top memory-consuming components |
org.eclipse.mat.api:compare | Comparison report (requires -baseline /path/to/other.hprof) |
org.eclipse.mat.api:suspects2 | Leak suspects comparison |
org.eclipse.mat.api:overview2 | Overview comparison |
Examples:
# Leak suspects
scripts/mat.sh report dump.hprof org.eclipse.mat.api:suspects
# Overview
scripts/mat.sh report dump.hprof org.eclipse.mat.api:overview
# Comparison (two heap dumps)
scripts/mat.sh report dump.hprof org.eclipse.mat.api:compare -baseline baseline.hprofReports generate HTML/ZIP artifacts in the same directory as the heap dump.
4. OQL Query — Execute Object Query Language queries
scripts/mat.sh oql /path/to/dump.hprof "<query>" [--format txt|html|csv] [--limit N]Examples:
# List all String objects
scripts/mat.sh oql dump.hprof "SELECT * FROM java.lang.String" --limit 100
# Inspect fields of a specific object by address
scripts/mat.sh oql dump.hprof "SELECT p.topic FROM OBJECTS 0x12345678 p"
# Find instances of a class
scripts/mat.sh oql dump.hprof "SELECT p FROM INSTANCEOF com.example.MyClass p" --limit 505. Run Command — Execute built-in MAT analysis commands
scripts/mat.sh command /path/to/dump.hprof <command_name> [args] [--format txt|html|csv] [--limit N]Examples:
# Class histogram
scripts/mat.sh command dump.hprof histogram
# Dominator tree
scripts/mat.sh command dump.hprof dominator_tree
# Path to GC roots for a specific object
scripts/mat.sh command dump.hprof path2gc 0x12345678
# Thread overview
scripts/mat.sh command dump.hprof thread_overview
# Find strings
scripts/mat.sh command dump.hprof find_strings --limit 200Supported Commands (56 total)
See references/commands.md for the full list with descriptions.
OQL Specification
MAT uses its own OQL dialect in "parse-application command mode":
Command format: -command=oql "<query>"
Supported Patterns
| Pattern | Example | Use Case |
| Instance scan | SELECT p FROM INSTANCEOF com.example.MyClass p | Iterate objects by class |
| Field extraction | SELECT p.topic FROM OBJECTS 0x12345678 p | Read fields from a specific object |
| Boolean/state check | SELECT p.isClosing FROM OBJECTS 0x12345678 p | Validate lifecycle flags |
| Class histogram | Use org.eclipse.mat.api:overview report instead | Ranking classes by count/size |
Known Limitations
- SQL-like
GROUP BY/ORDER BYfrequently fail in parse-app query mode - Dialect-specific helpers like
classof(...)may be rejected depending on parser context - For ranking/top classes, prefer MAT overview/suspects reports then parse the artifacts
- For root-cause inspection, use targeted field-level OQL against object addresses
Instructions for Heap Dump Analysis
Recommended Workflow
- Healthcheck first: Run
scripts/mat.sh healthcheckto verify the setup - Check index status: Run
scripts/mat.sh index-status <heap>— if already indexed, subsequent operations will be faster - Start with overview: Run
scripts/mat.sh report <heap> org.eclipse.mat.api:overviewto get class histogram and system info - Run leak suspects: Run
scripts/mat.sh report <heap> org.eclipse.mat.api:suspectsfor automatic leak detection - Drill down: Use
scripts/mat.sh command <heap> histogramfor class-level breakdown, thendominator_treefor retained size analysis - Investigate specific objects: Use
scripts/mat.sh oql <heap> "SELECT ..."to inspect individual objects by address or class - Thread analysis: Use
scripts/mat.sh command <heap> thread_overviewto see thread stacks and local variables
Reading Results
- Reports generate HTML directories and ZIP files next to the heap dump (e.g.,
dump_Leak_Suspects/) - Queries and commands produce text results in
*_Query/pages/Query_Command*.txt - The script automatically displays text results and lists generated artifacts
- For HTML reports, read the generated files in the report directory
Tips
- First-time analysis of a heap dump triggers indexing, which can take minutes for large dumps. Subsequent operations reuse the index.
- Increase
MAT_XMXfor very large heap dumps (e.g.,MAT_XMX=8g) - Increase
MAT_TIMEOUTfor long-running analyses (e.g.,MAT_TIMEOUT=3600) - Use
--limitwith OQL and commands to avoid overwhelming output - The
path2gccommand is invaluable for understanding why objects are retained - Compare two heap dumps with
org.eclipse.mat.api:compareto find growth patterns
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

