mat 内存分析 Linux,JVM内存分析工具MAT使用简介
#?Memory?Analyzer使用簡介
markdown格式渲染異常請閱讀附件。
-?[Memory?Analyzer使用簡介](#memory-analyzer使用簡介)
-?[MAT?簡介](#mat-簡介)
-?[安裝](#安裝)
-?[圖形界面使用方式](#圖形界面使用方式)
-?[命令行使用方式](#命令行使用方式)
-?[線程dump](#線程dump)
-?[堆dump](#堆dump)
-?[圖形渲染與顯示問題](#圖形渲染與顯示問題)
##?MAT?簡介
分析JVM堆dump,?線程dump的工具,具體介紹參考官網(wǎng)?。
使用教程?。
##?安裝
-?根據(jù)下載頁面的信息,?安裝合適的JDK版本(如1.8),?配置?`JAVA_HOME`,?`PATH`?等環(huán)境變量。
-?下載MAT,解壓,添加到?`PATH`?環(huán)境變量中。
-?根據(jù)需要調整MAT的JVM參數(shù),配置文件?`MemoryAnalyzer.ini`。
-?如果要在沒有圖形界面的linux系統(tǒng)上使用,可能要安裝圖形渲染依賴。
-?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
#?執(zhí)行后產(chǎn)生的結果
-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.
總結
以上是生活随笔為你收集整理的mat 内存分析 Linux,JVM内存分析工具MAT使用简介的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【OpenCV 例程200篇】18. 图
- 下一篇: 【OpenCV 例程200篇】73. 二