jmap
輸出進(jìn)程、核心文件或遠(yuǎn)程調(diào)試服務(wù)器的共享對(duì)象內(nèi)存或者堆內(nèi)存的相關(guān)信息霸褒。
語(yǔ)法
jmap [ options ] pid
jmap [ options ] executable core
jmap [ options ] [ pid ] server-id@ ] remote-hostname-or-IP
解釋
-
executable
產(chǎn)生核心轉(zhuǎn)儲(chǔ)的Java可執(zhí)行文件
-
core
打印內(nèi)存信息的核心文件
-
remote-hostname-or-IP
遠(yuǎn)程調(diào)試服務(wù)器的
hostname
或者IP
地址接箫。查看jsadebug -
server-id
遠(yuǎn)程服務(wù)器上有多個(gè)調(diào)試服務(wù)器時(shí),提供的調(diào)式服務(wù)器唯一ID
-
通過(guò)``-J-d64
可以指定
jmap`運(yùn)行在64位JVM上jmap -J-d64 -heap pid
Options
<no option>
沒(méi)有option參數(shù)右锨,jmap
命令輸出共享對(duì)象映射信息咏窿。會(huì)輸出JVM中所有共享對(duì)象的起始地址、映射大小撤卢、文件的全路徑
$ jmap 5208
Attaching to process ID 5208, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.40-b25
0x0000000056140000 8716K D:\path\Java\java1.8\64_jdk1.8.0_40\jre\bin\server\jvm.dll
0x00000000569d0000 840K D:\path\Java\java1.8\64_jdk1.8.0_40\jre\bin\msvcr100.dll
0x0000000056e10000 52K D:\path\Java\java1.8\64_jdk1.8.0_40\jre\bin\management.dll
0x0000000056e20000 68K D:\path\Java\java1.8\64_jdk1.8.0_40\jre\bin\nio.dll
0x0000000056e40000 104K D:\path\Java\java1.8\64_jdk1.8.0_40\jre\bin\net.dll
0x0000000056e60000 88K D:\path\Java\java1.8\64_jdk1.8.0_40\jre\bin\zip.dll
-dump:[live,] format=b, file=*filename*
- 將Java堆信息存入filename指定文件名的
hprof
二進(jìn)制文件中环凿; -
live
是可選操作,指定live
表示只保存活躍對(duì)象放吩; - 使用
jhat
命令可以讀取文件智听;
$ jmap -dump:live,format=b,file=test 5208
Dumping heap to C:\user\username\Desktop\test ...
Heap dump file created
$ jhat C:\\Users\\username\\Desktop\\test
Reading from C:\Users\username\Desktop\test...
Dump file created Fri Dec 27 13:20:01 CST 2019
Snapshot read, resolving...
Resolving 502739 objects...
Chasing references, expect 100 dots....................................................................................................
Eliminating duplicate references....................................................................................................
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.
訪(fǎng)問(wèn)localhost:7000可以查看文件具體內(nèi)容
finalizerinfo
$ jmap -finalizerinfo 10864
Attaching to process ID 10864, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.40-b25
Number of objects pending for finalization: 0
heap
輸出堆垃圾回收的摘要信息,配置信息屎慢,各年代的堆使用信息以及 interned Strings的是數(shù)量和大小瞭稼。
$ jmap -heap 10864
Attaching to process ID 10864, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.40-b25
using thread-local object allocation.
Garbage-First (G1) GC with 4 thread(s)
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 1073741824 (1024.0MB)
NewSize = 1363144 (1.2999954223632812MB)
MaxNewSize = 643825664 (614.0MB)
OldSize = 5452592 (5.1999969482421875MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 268435456 (256.0MB)
G1HeapRegionSize = 1048576 (1.0MB)
Heap Usage:
G1 Heap:
regions = 1024
capacity = 1073741824 (1024.0MB)
used = 402117216 (383.4888610839844MB)
free = 671624608 (640.5111389160156MB)
37.45008409023285% used
G1 Young Generation:
Eden Space:
regions = 341
capacity = 572522496 (546.0MB)
used = 357564416 (341.0MB)
free = 214958080 (205.0MB)
62.45421245421245% used
Survivor Space:
regions = 31
capacity = 32505856 (31.0MB)
used = 32505856 (31.0MB)
free = 0 (0.0MB)
100.0% used
G1 Old Generation:
regions = 15
capacity = 468713472 (447.0MB)
used = 10998368 (10.488861083984375MB)
free = 457715104 (436.5111389160156MB)
2.34650136107033% used
22533 interned Strings occupying 2048048 bytes.
histo[:live]
- 將堆信息以列表(histogram)的形式輸出;
- 輸出每個(gè)類(lèi)的信息:對(duì)象個(gè)數(shù)腻惠、內(nèi)存字節(jié)數(shù)环肘、全路徑;
- 如果指定
live
集灌,只統(tǒng)計(jì)活躍對(duì)象信息(從以下輸出可以看到對(duì)象數(shù)是不同的)
$ jmap -histo 10864
num #instances #bytes class name
----------------------------------------------
1: 887212 198868312 [C
2: 423381 89093320 [B
3: 46645 26477944 [I
4: 542764 13026336 java.lang.String
5: 128620 12347520 sun.util.calendar.Gregorian$Date
6: 128391 10271280 java.util.zip.ZipEntry
7: 92913 4668984 [Ljava.lang.Object;
8: 112727 2705448 java.util.Date
9: 46899 2626344 java.util.stream.ReferencePipeline$Head
10: 48749 1949960 java.security.AccessControlContext
11: 82135 1814832 [Ljava.lang.Class;
12: 14411 1632616 java.lang.Class
13: 50674 1621568 java.util.HashMap$Node
14: 46875 1500000 java.util.Spliterators$ArraySpliterator
15: 16237 1314488 [Ljava.util.HashMap$Node;
16: 14048 1236224 java.lang.reflect.Method
17: 35411 1133152 java.util.concurrent.ConcurrentHashMap$Node
18: 46864 1124736 java.util.stream.MatchOps$$Lambda$45/319558327
19: 40542 973008 java.lang.StringBuilder
20: 19482 935136 java.util.HashMap
21: 26831 870296 [Ljava.security.ProtectionDomain;
22: 33581 805944 org.apache.commons.collections.map.ListOrderedMap$ListOrderedMapEntry
23: 9684 772896 [S
24: 46864 749824 org.apache.jorphan.reflect.ClassFinder$ExtendsClassFilter$$Lambda$44/1397381784
25: 20407 653024 java.util.ArrayList$Itr
26: 10000 640000 java.awt.event.InvocationEvent
27: 18944 606208 java.util.concurrent.locks.AbstractQueuedSynchronizer$Node
28: 18127 580064 java.util.Hashtable$Entry
29: 17336 554752 java.beans.PropertyChangeEvent
30: 13686 547440 java.lang.ref.Finalizer
31: 31829 509264 java.lang.Object
32: 19459 467016 java.util.ArrayList
....................
3770: 1 16 sun.text.normalizer.NormalizerImpl$FCDTrieImpl
3771: 1 16 sun.text.normalizer.NormalizerImpl$NormTrieImpl
3772: 1 16 sun.util.CoreResourceBundleControl
3773: 1 16 sun.util.calendar.Gregorian
3774: 1 16 sun.util.locale.InternalLocaleBuilder$CaseInsensitiveChar
3775: 1 16 sun.util.locale.provider.AuxLocaleProviderAdapter$NullProvider
3776: 1 16 sun.util.locale.provider.CalendarDataUtility$CalendarFieldValueNamesMapGetter
3777: 1 16 sun.util.locale.provider.CalendarDataUtility$CalendarWeekParameterGetter
3778: 1 16 sun.util.locale.provider.CalendarNameProviderImpl$LengthBasedComparator
3779: 1 16 sun.util.locale.provider.SPILocaleProviderAdapter
3780: 1 16 sun.util.locale.provider.TimeZoneNameUtility$TimeZoneNameGetter
3781: 1 16 sun.util.resources.LocaleData
3782: 1 16 sun.util.resources.LocaleData$LocaleDataResourceBundleControl
Total 3659918 405059648
$ jmap -histo:live 10864
num #instances #bytes class name
----------------------------------------------
1: 7681 6404584 [B
2: 74426 6304912 [C
3: 13259 4714608 [I
4: 72674 1744176 java.lang.String
5: 14411 1632616 java.lang.Class
......................
3034: 1 16 sun.util.locale.provider.SPILocaleProviderAdapter
3035: 1 16 sun.util.locale.provider.TimeZoneNameUtility$TimeZoneNameGetter
3036: 1 16 sun.util.resources.LocaleData
3037: 1 16 sun.util.resources.LocaleData$LocaleDataResourceBundleControl
Total 561269 36751776
clstats
- 輸出Java堆中類(lèi)加載器的統(tǒng)計(jì)信息悔雹;
- 輸出每個(gè)類(lèi)加載器的信息:名稱(chēng),狀態(tài)欣喧,地址腌零,父類(lèi)加載器,已加載的類(lèi)的數(shù)量和大兴舭ⅰ益涧;
- 統(tǒng)計(jì)會(huì)比較耗費(fèi)時(shí)間;
$ jmap -clstats 10864
Attaching to process ID 10864, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.40-b25
finding class loader instances ..done.
computing per loader stat ..done.
please wait.. computing liveness..........................................................liveness analysis may be inaccurate ...
class_loader classes bytes parent_loader alive? type
<bootstrap> 3835 6981748 null live <internal>
0x00000000c02ccba8 1 1471 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c1aa4420 1 878 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c02cd820 1 1472 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c202e190 1 878 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c1c3e350 1 878 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c1dbe048 1 1472 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c02ccd38 1 1472 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c134d6a0 1 1471 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c03acea0 1 1471 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c02cc7b0 10587 13944043 0x00000000c0300be8 live org/apache/jmeter/DynamicClassLoader@0x0000000100060218
0x00000000c1e0fe40 1 878 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c10256a0 1 1471 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c02cc888 1 1481 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c19dc138 1 1471 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c19dcb38 1 1473 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c19e6fb8 1 1473 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c19aa9b0 1 1473 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c1aa5000 1 878 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c02cce00 1 1472 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c0fd55d0 12 37189 0x00000000c0300be8 live sun/reflect/misc/MethodUtil@0x00000001001e1028
0x00000000c0ef5fc0 1 878 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c02cca18 1 1472 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c0270990 0 0 0x00000000c0300be8 live java/util/ResourceBundle$RBClassLoader@0x00000001000f2f58
0x00000000c0fd4ec0 1 878 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c0ef6450 1 1471 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c1025440 1 878 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c02cd8e8 1 1472 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c037f870 1 1471 0x00000000c02ccec8 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c1eac520 1 878 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c1fb10b0 1 878 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c02ccae0 1 1472 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c03d5370 1 878 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c10a22d8 1 1471 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c23a9668 1 878 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c0300be8 37 144387 0x00000000c02ccec8 live sun/misc/Launcher$AppClassLoader@0x000000010000f668
0x00000000c02ccc70 1 1471 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c13df1e0 1 1472 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c1522db0 1 1471 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c202e8e0 1 878 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c02ccec8 152 345291 null live sun/misc/Launcher$ExtClassLoader@0x000000010000fa10
0x00000000c20611e0 1 1471 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c0ef6108 1 878 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c19e2e70 1 1473 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c1fe6910 1 878 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c206a068 1 878 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c10a1ef8 1 878 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c0fd5088 1 889 0x00000000c0fd55d0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c13d75c8 1 1473 null dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c1e25298 1 1471 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c02cc950 1 1471 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
0x00000000c23c42c0 1 878 0x00000000c02cc7b0 dead sun/reflect/DelegatingClassLoader@0x0000000100009df8
total = 52 14669 21509096 N/A alive=6, dead=46 N/A
F
強(qiáng)制輸出
- 使用
jmap -dump
或者jmap -histo
命令時(shí)驯鳖,如果進(jìn)程沒(méi)有響應(yīng)闲询,可以使用-F
強(qiáng)制輸出久免; -
live
模式下不能使用-F
強(qiáng)制輸出;
h
help
-h
與-help
都是輸出幫助信息的指令
-Jflag
將flag
信息傳遞給運(yùn)行jamp
命令的虛擬機(jī)
其他文章列表
spring web service系列1
spring web service系列2
spring web service系列3
maven配置文件settings.xml詳解
Nginx轉(zhuǎn)發(fā)請(qǐng)求過(guò)程解析
Nginx中的負(fù)載均衡算法
Nginx upstream指令配置說(shuō)明
Nginx中虛擬服務(wù)器server指令配置說(shuō)明
Nginx中proxy_pass/proxy_redirect/proxy_set_header配置說(shuō)明
Nginx中ngx_http_core_module相關(guān)指令配置說(shuō)明
Java自帶JVM監(jiān)控工具jstat使用詳細(xì)說(shuō)明
Java自帶JVM監(jiān)控工具jps使用詳細(xì)說(shuō)明
Java自帶故障分析工具jhat工具使用說(shuō)明