mat 内存分析 Linux,JVM内存分析工具MAT使用简介

# Memory Analyzer使用简介

markdown格式渲染异常请阅读附件。

- [Memory Analyzer使用简介](#memory-analyzer使用简介)

- [MAT 简介](#mat-简介)

- [安装](#安装)

- [图形界面使用方式](#图形界面使用方式)

- [命令行使用方式](#命令行使用方式)

- [线程dump](#线程dump)

- [堆dump](#堆dump)

- [图形渲染与显示问题](#图形渲染与显示问题)

## MAT 简介

分析JVM堆dump, 线程dump的工具,具体介绍参考官网 。

使用教程 。

## 安装

- 根据下载页面的信息, 安装合适的JDK版本(如1.8), 配置 `JAVA_HOME`, `PATH` 等环境变量。

- 下载MAT,解压,添加到 `PATH` 环境变量中。

- 根据需要调整MAT的JVM参数,配置文件 `MemoryAnalyzer.ini`。

- 如果要在没有图形界面的linux系统上使用,可能要安装图形渲染依赖。

- redhat系列可以使用 `yum groupinstall x11` 安装依赖。

- debian系列 `apt install x-window-system-core`。

- 可能需要安装一些字体:`yum install xorg-x11-fonts* wqy*` 或 `apt install wqy*`

## 图形界面使用方式

直接打开软件,从菜单打开dump文件分析,默认生成的分析视图可以比较清晰的看出堆内的内存占用情况。

## 命令行使用方式

官方文档称为 `Batch mode`。

使用命令方式分析dump文件,会在dump文件所在目录生成3个zip文件。将zip文件解压到特定目录,使用浏览器打开目录里面的index.html查看分析结果。

```bash

$ ParseHeapDump.sh /mnt/tmp/dump.hprof org.eclipse.mat.api:suspects org.eclipse.mat.api:overview org.eclipse.mat.api:top_components

# 执行后产生的结果

-rw-r--r-- 1 root   root 235K Jun 19 09:43 dump_Top_Components.zip

-rw-r--r-- 1 root   root  84K Jun 19 09:43 dump_System_Overview.zip

-rw-r--r-- 1 root   root  98K Jun 19 09:43 dump_Leak_Suspects.zip

```

>For a simple suspects report use org.eclipse.mat.api:suspects

>

>For an overview report use org.eclipse.mat.api:overview

>

>For a report on memory usage by component use org.eclipse.mat.api:top_components

>

>To compare two heap dumps use./mat/ParseHeapDump.sh myheapdump.hprof -snapshot2=myheapdump2.

>hprof org.eclipse.mat.api:compare

## 线程dump

```bash

jstack -l {$pid} >> jstack.tdump

```

## 堆dump

```bash

jmap -dump:format=b,file=dump.hprof {$pid}

```

## 图形渲染与显示问题

错误信息类似

>Failed to create a browser because of: org.eclipse.swt.SWTException: Failed to execute >runnable (org.eclipse.swt.SWTError: No more handles because no underlying browser available.

>org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTError: XPCOM >error -2147467259)

>

>Failed to create a browser because of: No more handles because no underlying browser >available. Please ensure Webkit with its Gtk 3.x bindings installed. Webkit2 API level >preferred.

主要是缺少图形渲染使用的包: webkit2gtk.

>Note:

>On a Linux®1 system, make sure that webkit2gtk-4.0 is installed.

>

>Select the latest version available of webkit2gtk-4.0 and install it.

>

>On an Ubuntu®2 Linux® system use commands such as

>

>sudo apt-get update

>sudo apt-get install libwebkit2gtk-4.0

>

>On a Red Hat®3 Linux® system use yum

>

>yum install webkitgtk4

>

>The operating system should confirm that webkit2gtk-4 has been properly installed

>

>Restart Memory Analyzer

>

>Open a heap dump.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值