2016年(22)
分类: 系统运维
2016-05-31 17:44:05
// 打印jvm的堆状况,主要是年轻代和老年代信息
jmap -heap
如:
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 536870912 (512.0MB)
NewSize = 1310720 (1.25MB)
MaxNewSize = 17592186044415 MB
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 21757952 (20.75MB)
MaxPermSize = 268435456 (256.0MB)
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 46661632 (44.5MB)
used = 1139464 (1.0866775512695312MB)
free = 45522168 (43.41332244873047MB)
2.441972025324789% used
From Space:
capacity = 524288 (0.5MB)
used = 0 (0.0MB)
free = 524288 (0.5MB)
0.0% used
To Space:
capacity = 1048576 (1.0MB)
used = 0 (0.0MB)
free = 1048576 (1.0MB)
0.0% used
PS Old Generation
capacity = 112721920 (107.5MB)
used = 54152304 (51.64366149902344MB)
free = 58569616 (55.85633850097656MB)
48.04061534792878% used
PS Perm Generation
capacity = 94371840 (90.0MB)
used = 94050296 (89.69335174560547MB)
free = 321544 (0.30664825439453125MB)
99.65927971733942% used
37542 interned Strings occupying 3976528 bytes.
// 上面的信息比较笼统,我们还可以打印出具体类及实例信息, 将有助于帮助我们分析堆里面到底有哪些类的实例等
jmap -histo[:live只处理存活对象]
如,
num #instances #bytes class name
----------------------------------------------
1: 152516 24683264
2: 152516 19540560
3: 15131 18875008
4: 201534 18312296 [C
5: 15131 11855656
6: 12595 10850176
7: 94350 5198896 [B
8: 182201 4372824 java.lang.String
9: 109840 3514880 java.util.HashMap$Entry
10: 18069 2334792 [Ljava.util.HashMap$Entry;
11: 3889 2233712
12: 46910 2159984 [Ljava.lang.Object;
13: 16277 2034144 java.lang.Class
// 可以将堆信息dump成文件,通过jhat, mat做分析
jmap -dump:live,format=b,file=heap.bin