java-heap-dump-triage

Analyzes Java heap dumps and MAT reports to trace retained memory back to source code.

2.5k|524|Updated May 29, 2019
One-click install
npx skills add https://github.com/TencentBlueKing/bk-ci --skill java-heap-dump-triage
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: java-heap-dump-triage
Source: https://github.com/TencentBlueKing/bk-ci/tree/main/ai/skills/java-heap-dump-triage
Command: npx skills add https://github.com/TencentBlueKing/bk-ci --skill java-heap-dump-triage

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Diagnosing Java memory leaks and OOM failures from heap dumps is slow and error-prone: raw .hprof files are opaque, MAT reports are verbose, and connecting retained heap evidence back to actual project code requires deep JVM and framework knowledge. This Skill turns heap dump evidence into an actionable engineering diagnosis with a falsifiable root cause, a concrete fix, and a verification plan.

Core Features & Use Cases

  • MAT Report Generation and Parsing: Locates .hprof files and MAT report zips, generates Leak Suspects, System Overview, and Top Components reports via the Eclipse MAT command line when only a raw dump exists, and extracts class histograms, dominator trees, thread overviews, and system properties from the HTML output.
  • Retained Heap Root Cause Analysis: Identifies the true accumulation points (caches, schedulers, ThreadLocals, classloaders, queues) using retained heap and dominator paths rather than misleading shallow heap numbers.
  • Code-Level Correlation: Searches the repository with ripgrep to map suspicious classes and frameworks back to Java/Kotlin/Spring/Quartz code, checking lifecycle symmetry (add/remove, schedule/delete, put/evict) and key identity consistency.
  • Use Case: A service keeps hitting OOM and a 2.6 GB heap dump shows Quartz RAMJobStore dominating retained heap. The Skill traces the leak to a deleteJob call using the wrong job group, proposes a minimal fix, and defines restart and re-dump verification steps.

Quick Start

Analyze this heap dump or MAT report, find the retained memory root cause, correlate it with my project code, and give me a fix and verification plan in Chinese.

Frequently Asked Questions about java-heap-dump-triage

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I analyze a Java heap dump file for memory leaks?

Heap dump analysis starts by generating Eclipse MAT reports (Leak Suspects, System Overview, Top Components) from the .hprof file using ParseHeapDump.sh, then examining retained heap and dominator trees to find accumulation points. The findings are then correlated back to source code to identify the leaking lifecycle.

How to generate Eclipse MAT reports from a .hprof file via command line?

Run ParseHeapDump.sh with the dump path and report types: org.eclipse.mat.api:suspects, org.eclipse.mat.api:overview, and org.eclipse.mat.api:top_components. This produces Leak_Suspects, System_Overview, and Top_Components zip files alongside the dump without deleting the original .hprof.

Why does Quartz RAMJobStore cause high retained heap?

RAMJobStore retains all scheduled jobs and triggers in process memory, so leaks typically come from lifecycle asymmetry: deleteJob called with the wrong job group, reload logic that re-schedules without checking existing jobs, or expired timer records never removed from Quartz. The dominator path usually shows QuartzSchedulerResources holding CronTriggerImpl and TriggerWrapper objects.

What is the difference between shallow heap and retained heap in MAT?

Shallow heap is the memory an object itself occupies, while retained heap is the total memory that would be freed if that object were garbage collected. Leak diagnosis should prioritize retained heap and dominator trees, since high shallow heap objects are often just entries held by a larger leaking collection.

Can this analyze a heap dump without an existing MAT report?

Yes. If only a raw .hprof file exists, the Skill locates the Eclipse MAT command line tool (ParseHeapDump.sh or MemoryAnalyzer) and generates the three standard reports before analysis. Large dumps may produce truncated terminal output, so success is judged by exit code and generated artifacts.

When should ThreadLocal or thread count not be blamed for a memory leak?

Thread count should not be treated as the root cause when retained heap is dominated by other structures, unless ThreadLocal or thread stacks directly retain large objects. For example, a QuartzSchedulerThread waiting in run() is usually just a retention path, not the leak source.