功能:可以分析jmap dump下的hprof文件
一般配合
jmap -dump:format=b,file=dumpFileName pid
或者
jmap -histo:live 21711 | more
jmap -histo:live 21711 | more num #instances #bytes class name ---------------------------------------------- 1: 38445 5597736 <constMethodKlass> 2: 38445 5237288 <methodKlass> 3: 3500 3749504 <constantPoolKlass> 4: 60858 3242600 <symbolKlass> 5: 3500 2715264 <instanceKlassKlass> 6: 2796 2131424 <constantPoolCacheKlass> 7: 5543 1317400 [I 8: 13714 1010768 [C 9: 4752 1003344 [B 10: 1225 639656 <methodDataKlass> 11: 14194 454208 java.lang.String 12: 3809 396136 java.lang.Class 13: 4979 311952 [S 14: 5598 287064 [[I 15: 3028 266464 java.lang.reflect.Method 16: 280 163520 <objArrayKlassKlass> 17: 4355 139360 java.util.HashMap$Entry 18: 1869 138568 [Ljava.util.HashMap$Entry; 19: 2443 97720 java.util.LinkedHashMap$Entry 20: 2072 82880 java.lang.ref.SoftReference 21: 1807 71528 [Ljava.lang.Object; 22: 2206 70592 java.lang.ref.WeakReference 23: 934 52304 java.util.LinkedHashMap 24: 871 48776 java.beans.MethodDescriptor 25: 1442 46144 java.util.concurrent.ConcurrentHashMap$HashEntry 26: 804 38592 java.util.HashMap 27: 948 37920 java.util.concurrent.ConcurrentHashMap$Segment 28: 1621 35696 [Ljava.lang.Class; 29: 1313 34880 [Ljava.lang.String; 30: 1396 33504 java.util.LinkedList$Entry 31: 462 33264 java.lang.reflect.Field 32: 1024 32768 java.util.Hashtable$Entry 33: 948 31440 [Ljava.util.concurrent.ConcurrentHashMap$HashEntry;
class name是对象类型,说明如下:
B byte
C char
D double
F float
I int
J long
Z boolean
[ 数组,如[I表示int[]
[L+类名 其他对象
命令:
jhat -J-Xmx1024m D:\myProject\project\httpclientTest\java_pid4652.hprof
输出:
C:\Users\xinchun.wang>jhat -J-Xmx1024m D:\myProject\project\httpclientTest\java_pid4652.hprof Reading from D:\myProject\project\httpclientTest\java_pid4652.hprof... Dump file created Sun May 14 19:22:48 CST 2017 Snapshot read, resolving... Resolving 818455 objects... Chasing references, expect 163 dots................................................................................................. Eliminating duplicate references.................................................................................................... Snapshot resolved. Started HTTP server on port 7000 Server is ready.
浏览器输入:http://127.0.0.1:7000/
展示:
All Classes (excluding platform) Package <Default Package> class Test [0xff392c48] class Test$OOMObject [0xff392bd8] Other Queries All classes including platform Show all members of the rootset Show instance counts for all classes (including platform) Show instance counts for all classes (excluding platform) Show heap histogram Show finalizer summary Execute Object Query Language (OQL) query