首页 > 编程知识 正文

jmap分析工具,jmap dump

时间:2023-05-05 06:36:59 阅读:186487 作者:3941

本系列笔记主要基于《深入理解Java虚拟机:JVM高级特性与最佳实践 第2版》,是这本书的读书笔记。

jmap命令用于生成内存堆转储的快照,通常称为heapdump或dump文件。

除了使用jmap命令外,还使用一些JVM参数在虚拟机内存溢出时自动将快照文件dump出。

参数

说明

- xx : heapdumponoutofmemoryerror

内存溢出时自动导出内存快照

- xx : heap dump path=e :/dumps /

导出内存快照时保存的路径

所有JDK工具都位于Oracle官方网站的Java Tools Reference文档中。 这是命令格式、参数内容和输出信息等主要参考。

jap命令格式:

jmap [ options ] pid

jmap [ options ] executable core

jmap [ options ] [ PID ] server-id @ ] remote-hostname-or-IP

jmap帮助信息:

jmap -dump

jmap命令使用-dump参数生成内存快照。 -dump参数的格式如下:

-dump:[live,] format=b,file=filename

例如以下所示。

jmap -dump:format=b,file=/dumps/jmap.hprof 21060

输出如下。

请注意,在指定的目录dumps下生成了堆快照文件。

jmap -heap

jmap命令使用-heap参数显示堆内存配置信息和堆中每个区域的使用情况,包括新生代Eden和Survivor区域以及旧的年代。

-heap参数示例:

jmap -heap 21060

输出如下。

其他参数

jmap命令提供了许多其他参数,您可以在其中查看Java工具引用文档。 以下列举。

When no option is used,thejmapcommandprintssharedobjectmappings.foreachsharedobjectloadedinthetargetjvm,the start address,sid andthefullpathofthesharedobjectfileareprinted.thisbehaviorissimilartotheoraclesolarispmaputility。

-dump:[live,] format=b,file=filename

dumpsthejavaheapinhprofbinaryformattofilename.thelivesuboptionisoptional,but when specified, onlytheactiveobjectsintheheaparedumped.tobrowsetheheapdump,youcanusethejhat(1) command to read the generated file。

-finalizerinfo

printsinformationaboutobjectsthatareawaitingfinalization

-头儿

printsaheapsummaryofthegarbagecollectionused,the head configuration,and generation-wiseheapusage.in addition,thenumberanber

-Histo[:直播]

printsahistogramoftheheap.foreach Java class,the number of objects,memory size in bytes, andthefullyqualifiedclassnamesareprinted.thejvminternalclassnamesareprintedwithanasterisk (* ) prefix.ifthelivesuboptionistion

-clstats

printsclassloaderwisestatisticsofjavaheap.foreach class loader,its name,how active it is,address,parent class loader,and the

-F

force.usethisoptionwiththejmap-dumporjmap-histooptionwhenthepiddoesnotrespond.thelivesuboptionisuportedinthismode

-h

打印帮助消息。

-帮助

打印帮助消息。

-Jflag

passesflagtothejavavirtualmachinewherethejmapcommandisrunning。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。