jmap指令用来生成内存堆转储快照,一般称为heapdump或dump文件。
除了运用jmap指令,还以经过一些JVM参数让虚拟机在内存溢出时主动dump出快照文件。
参数阐明
-XX:+HeapDumpOnOutOfMemoryError内存溢出时主动导出内存快照
-XX:HeapDumpPath=E:/dumps/导出内存快照时保存的路径
所有的JDK工具都可以在Oracle官网的JavaToolsReference文档中找到运用阐明,这是首要参阅,包括指令格局、参数内容、输出信息等等。
jmap指令格局:
Copy
jmap[options]pidjmap[options]executablecorejmap[options][pid]server-id@]remote-hostname-or-IP
jmap帮助信息:
image
jmap-dump#
jmap指令运用-dump参数生成内存快照,-dump参数格局如下:
Copy
-dump:[live,]format=b,file=filename
举例如下:
Copy
jmap-dump:format=b,file=/dumps/jmap.hprof21060
输出如下:
image
可见,在指定目录dumps下面生成了堆快照文件。
jmap-heap#
jmap指令运用-heap参数检查堆内存的配置信息,以及堆中各个区域的运用情况,如新生代的Eden和Survivor区,还有老年代。
-heap参数举例如下:
Copy
jmap-heap21060
输出如下:
image
其他参数#
jmap指令还有许多其他参数,可以参阅JavaToolsReference文档,列举如下:
Copy
option>Whennooptionisused,thejmapcommandprintssharedobjectmappings.ForeachsharedobjectloadedinthetargetJVM,thestartaddress,sizeofthemapping,andthefullpathofthesharedobjectfileareprinted.ThisbehaviorissimilartotheOracleSolarispmaputility.
-dump:[live,]format=b,file=filename
DumpstheJavaheapinhprofbinaryformattofilename.Thelivesuboptionisoptional,butwhenspecified,onlytheactiveobjectsintheheaparedumped.Tobrowsetheheapdump,youcanusethejhat(1)commandtoreadthegeneratedfile.
-finalizerinfo
Printsinformationaboutobjectsthatareawaitingfinalization.
-heap
Printsaheapsummaryofthegarbagecollectionused,theheadconfiguration,andgeneration-wiseheapusage.Inaddition,thenumberandsizeofinternedStringsareprinted.
-histo[:live]
Printsahistogramoftheheap.ForeachJavaclass,thenumberofobjects,memorysizeinbytes,andthefullyqualifiedclassnamesareprinted.TheJVMinternalclassnamesareprintedwithanasterisk(*)prefix.Ifthelivesuboptionisspecified,thenonlyactiveobjectsarecounted.
-clstats
PrintsclassloaderwisestatisticsofJavaheap.Foreachclassloader,itsname,howactiveitis,address,parentclassloader,andthenumberandsizeofclassesithasloadedareprinted.
-F
Force.Usethisoptionwiththejmap-dumporjmap-histooptionwhenthepiddoesnotrespond.Thelivesuboptionisnotsupportedinthismode.
-h
Printsahelpmessage.
-help
Printsahelpmessage.
-Jflag
PassesflagtotheJavaVirtualMachinewherethejmapcommandisrunning.
1、IT大王遵守相关法律法规,由于本站资源全部来源于网络程序/投稿,故资源量太大无法一一准确核实资源侵权的真实性;
2、出于传递信息之目的,故IT大王可能会误刊发损害或影响您的合法权益,请您积极与我们联系处理(所有内容不代表本站观点与立场);
3、因时间、精力有限,我们无法一一核实每一条消息的真实性,但我们会在发布之前尽最大努力来核实这些信息;
4、无论出于何种目的要求本站删除内容,您均需要提供根据国家版权局发布的示范格式
《要求删除或断开链接侵权网络内容的通知》:https://itdw.cn/ziliao/sfgs.pdf,
国家知识产权局《要求删除或断开链接侵权网络内容的通知》填写说明: http://www.ncac.gov.cn/chinacopyright/contents/12227/342400.shtml
未按照国家知识产权局格式通知一律不予处理;请按照此通知格式填写发至本站的邮箱 wl6@163.com