https://www.jianshu.com/p/871d6bb3a32d
在服务器性能优化内存这一项时,有一些现象很诡异。如top显示的RES很大,但是实际jvm堆内存占用很小,同时使用nmt发现committed更大。所以决定写这篇wiki大概介绍一下
top(res)
$ top
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
14730 landon 20 0 9283m 1.6g 19m S 0.3 20.5 30:43.57 java
jstat
$ jstat -gc 14730
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
143360.0 143360.0 0.0 0.0 1146880.0 27569.6 4300800.0 88770.2 40448.0 39299.8 4648.0 4382.2 18 1.441 4 1.213 2.654
$ jstat -gcutil 14730
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
0.00 0.00 2.40 2.06 97.16 94.28 18 1.441 4 1.213 2.654
jmap
$ jmap -heap 14730
Attaching to process ID 14730, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.172-b11
using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 5872025600 (5600.0MB)
NewSize = 1468006400 (1400.0MB)
MaxNewSize = 1468006400 (1400.0MB)
OldSize = 4404019200 (4200.0MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
New Generation (Eden + 1 Survivor Space):
capacity = 1321205760 (1260.0MB)
used = 44450000 (42.39082336425781MB)
free = 1276755760 (1217.6091766357422MB)
3.364351060655382% used
Eden Space:
capacity = 1174405120 (1120.0MB)
used = 44450000 (42.39082336425781MB)
free = 1129955120 (1077.6091766357422MB)
3.7848949432373047% used
From Space:
capacity = 146800640 (140.0MB)
used = 0 (0.0MB)
free = 146800640 (140.0MB)
0.0% used
To Space:
capacity = 146800640 (140.0MB)
used = 0 (0.0MB)
free = 146800640 (140.0MB)
0.0% used
concurrent mark-sweep generation:
capacity = 4404019200 (4200.0MB)
used = 90900656 (86.68962097167969MB)
free = 4313118544 (4113.31037902832MB)
2.0640385945638022% used
14494 interned Strings occupying 1262456 bytes.
$ jmap -histo:live 14730 | head -13
num #instances #bytes class name
----------------------------------------------
1: 341052 13981272 [C
2: 194673 11402072 [Ljava.lang.Object;
3: 337876 8109024 java.lang.String
4: 227540 7281280 java.util.HashMap$Node
5: 180237 7209480 landon.WordFilterService$WordNode
6: 62226 5685448 [Ljava.util.HashMap$Node;
7: 220913 5301912 java.util.ArrayList
8: 17448 4789712 [B
9: