Skip to content

About

dump-analyzer - AI-Powered Java Heap Dump Analysis Skill that deeply analyzes Java heap dump files (.hprof) using Eclipse Memory Analyzer Tool (MAT) to automatically identify root causes of memory leaks and OutOfMemoryError (OOM).

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dump文件分析器 (MAT版) | Dump File Analyzer (MAT Version)

中文 | English


中文文档

使用 Eclipse Memory Analyzer Tool (MAT) 深度分析 Java 堆转储文件(.hprof),提供完整的内存分析报告。

依赖要求

  • 必需: Eclipse MAT 1.15+ 已安装
  • 环境变量: MAT_HOME 指向 MAT 安装目录

安装 MAT

  1. 下载 Eclipse MAT: https://www.eclipse.org/mat/downloads.php
  2. 解压到本地目录(如 D:\Develop\MAT\mat)
  3. 设置环境变量 MAT_HOME
# 临时设置(当前会话)
$env:MAT_HOME = "D:\Develop\MAT\mat"

# 永久设置
[System.Environment]::SetEnvironmentVariable("MAT_HOME", "D:\Develop\MAT\mat", "User")

使用方法

基本分析流程

# 1. 检测 MAT 环境(自动搜索常见路径)
$matPaths = @(
    "C:\Program Files\Eclipse\MAT",
    "C:\MAT",
    "D:\Develop\MAT\mat",
    "D:\MAT"
)

$foundMat = $null
foreach ($path in $matPaths) {
    if (Test-Path "$path\ParseHeapDump.bat") {
        $foundMat = $path
        break
    }
}

if ($foundMat) {
    $env:MAT_HOME = $foundMat
    Write-Host "找到 MAT: $foundMat"
} else {
    Write-Host "未找到 MAT,请安装或手动设置 MAT_HOME"
}

# 2. 执行 MAT 分析(生成 Leak Suspects Report)
& "$env:MAT_HOME\ParseHeapDump.bat" C:\path\to\heapdump.hprof org.eclipse.mat.api:suspects

# 3. 解压报告
Expand-Archive -Path "C:\path\to\heapdump.hprof_Leak_Suspects.zip" -DestinationPath "mat-report" -Force

# 4. 分析报告文件
# - mat-report/index.html - 泄漏嫌疑点摘要
# - mat-report/pages/System_Overview2.html - 系统概览
# - mat-report/pages/Class_Histogram7.html - 类直方图
# - mat-report/pages/Thread_Overview5.html - 线程概览
# - mat-report/pages/Top_Consumers6.html - 大对象分析

使用脚本分析

# Windows
.\scripts\mat-analyzer.bat C:\path\to\heapdump.hprof C:\output\dir

# Linux/Mac
./scripts/mat-analyzer.sh /path/to/heapdump.hprof /output/dir

完整分析报告维度

分析报告包含以下所有维度(无论是否有问题):

  1. 系统概览 (System Overview) - 堆内存、对象数、类数、GC Roots
  2. 泄漏嫌疑点分析 (Leak Suspects) - 内存泄漏检测
  3. 类直方图 (Class Histogram) - Top N 内存占用类
  4. 线程概览 (Thread Overview) - 所有线程状态和堆栈
  5. 大对象分析 (Top Consumers) - 单个最大对象
  6. 支配树分析 (Dominator Tree) - 对象引用关系
  7. GC Roots 分析 - 阻止回收的根引用
  8. 系统属性 (System Properties) - JVM 参数和环境变量

故障排除

MAT_HOME 未设置

$env:MAT_HOME = "D:\Develop\MAT\mat"

分析大文件时内存不足

编辑 MemoryAnalyzer.ini,调整 -Xmx 参数:

-Xmx8g

English Documentation

Uses Eclipse Memory Analyzer Tool (MAT) to deeply analyze Java heap dump files (.hprof) and provide comprehensive memory analysis reports.

Requirements

  • Required: Eclipse MAT 1.15+ installed
  • Environment Variable: MAT_HOME pointing to MAT installation directory

Installing MAT

  1. Download Eclipse MAT: https://www.eclipse.org/mat/downloads.php
  2. Extract to local directory (e.g., D:\Develop\MAT\mat)
  3. Set environment variable MAT_HOME
# Temporary (current session)
$env:MAT_HOME = "D:\Develop\MAT\mat"

# Permanent
[System.Environment]::SetEnvironmentVariable("MAT_HOME", "D:\Develop\MAT\mat", "User")

Usage

Basic Analysis Workflow

# 1. Detect MAT environment (auto-search common paths)
$matPaths = @(
    "C:\Program Files\Eclipse\MAT",
    "C:\MAT",
    "D:\Develop\MAT\mat",
    "D:\MAT"
)

$foundMat = $null
foreach ($path in $matPaths) {
    if (Test-Path "$path\ParseHeapDump.bat") {
        $foundMat = $path
        break
    }
}

if ($foundMat) {
    $env:MAT_HOME = $foundMat
    Write-Host "Found MAT: $foundMat"
} else {
    Write-Host "MAT not found, please install or set MAT_HOME manually"
}

# 2. Execute MAT analysis (generate Leak Suspects Report)
& "$env:MAT_HOME\ParseHeapDump.bat" C:\path\to\heapdump.hprof org.eclipse.mat.api:suspects

# 3. Extract report
Expand-Archive -Path "C:\path\to\heapdump.hprof_Leak_Suspects.zip" -DestinationPath "mat-report" -Force

# 4. Analyze report files
# - mat-report/index.html - Leak suspects summary
# - mat-report/pages/System_Overview2.html - System overview
# - mat-report/pages/Class_Histogram7.html - Class histogram
# - mat-report/pages/Thread_Overview5.html - Thread overview
# - mat-report/pages/Top_Consumers6.html - Large object analysis

Using Scripts

# Windows
.\scripts\mat-analyzer.bat C:\path\to\heapdump.hprof C:\output\dir

# Linux/Mac
./scripts/mat-analyzer.sh /path/to/heapdump.hprof /output/dir

Complete Report Analysis Dimensions

The analysis report includes all the following dimensions (regardless of issues):

  1. System Overview - Heap memory, object count, class count, GC Roots
  2. Leak Suspects Analysis - Memory leak detection
  3. Class Histogram - Top N memory-consuming classes
  4. Thread Overview - All thread states and stacks
  5. Top Consumers - Individual largest objects
  6. Dominator Tree Analysis - Object reference relationships
  7. GC Roots Analysis - Root references preventing collection
  8. System Properties - JVM parameters and environment variables

Troubleshooting

MAT_HOME Not Set

$env:MAT_HOME = "D:\Develop\MAT\mat"

Out of Memory When Analyzing Large Files

Edit MemoryAnalyzer.ini, adjust -Xmx parameter:

-Xmx8g

相关资源 | Related Resources

Skill 文件 | Skill Files

  • SKILL.md - 中文版本 | Chinese version
  • SKILL_EN.md - English version

About

dump-analyzer - AI-Powered Java Heap Dump Analysis Skill that deeply analyzes Java heap dump files (.hprof) using Eclipse Memory Analyzer Tool (MAT) to automatically identify root causes of memory leaks and OutOfMemoryError (OOM).

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Contributors

Languages