zno2

MAT(3)获取dump文件

方式一:遇错时自动生成(添加启动参数)

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=E:\Java\dump

生成的文件例如:java_pid2080.hprof

方式二:运行时主动生成(jmap命令)

jmap -J-d64 -dump:format=b,file=E:\Java\dump\d1.hprof 7992 

生成的文件例如:d1.phrof

语法:

jmap [ option ] pid

window  打开任务管理器 - 进程 - 找到对应PID (如果表中没有,可 “查看 - 选择列 - PID " 展示 )

linux 使用命令 ps -ef 查找PID

-J<flag> Passes <flag> to the Java virtual machine on which jmap is run.

-J-d64 Means the given process is running on a 64-bit VM

-dump:[live,]format=b,file=<filename> Dumps the Java heap in hprof binary format to filename.

常见错误:

如果PID不正确则如下

20520: no such process

如果file指定的是一个已存在的文件夹而不是文件则如下

# 其中dump是一个已存在的文件夹
Dumping heap to E:\Java\dump ...
Permission denied

 hprof 由来:

The Java 2 Platform Standard Edition (J2SE) has always provided a simple command line profiling tool called HPROF for heap and cpu profiling.

Heap profile 工具生成的文件的格式就是 (*.hprof)

点击查看详细语法

posted on 2016-08-05 18:25  zno2  阅读(649)  评论(0编辑  收藏  举报

导航