1.使用jmap -heap pid查看进程堆内存使用情况,包括使用的GC算法、堆配置参数和各代中堆内存使用情况
[tomcat_admin@ceshi2 logs]$ jmap -heap 20327
Attaching to process ID 20327, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.60-b09
using thread-local object allocation.
Parallel GC with 8 thread(s)
Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 4294967296 (4096.0MB)
NewSize = 1572864000 (1500.0MB)
MaxNewSize = 1572864000 (1500.0MB)
OldSize = 5439488 (5.1875MB)
NewRatio = 1
SurvivorRatio = 6
PermSize = 134217728 (128.0MB)
MaxPermSize = 268435456 (256.0MB)
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 1497366528 (1428.0MB)
used = 765865088 (730.3858642578125MB)
free = 731501440 (697.6141357421875MB)
51.147469485841214% used
From Space:
capacity = 37224448 (35.5MB)
used = 28563848 (27.24060821533203MB)
free = 8660600 (8.259391784667969MB)
76.73410764882263% used
To Space:
capacity = 37748736 (36.0MB)
used = 0 (0.0MB)
free = 37748736 (36.0MB)
0.0% used
PS Old Generation
capacity = 2722103296 (2596.0MB)
used = 895285920 (853.8111877441406MB)
free = 1826817376 (1742.1888122558594MB)
32.8894910533182% used
PS Perm Generation
capacity = 202899456 (193.5MB)
used = 94202168 (89.83818817138672MB)
free = 108697288 (103.66181182861328MB)
46.428004222938874% used
41746 interned Strings occupying 4409600 bytes.
2.最后一次gc原因
jstat -gccause 20327
S0 S1 E O P YGC YGCT FGC FGCT GCT LGCC GCC
76.73 0.00 50.90 32.89 46.43 318 18.926 3 3.139 22.065 Allocation Failure No GC
3. jstat -gccapacity 20327
NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC PGCMN PGCMX PGC PC YGC FGC
1536000.0 1536000.0 1536000.0 36352.0 36864.0 1462272.0 2658304.0 2658304.0 2658304.0 2658304.0 131072.0 262144.0 198144.0 198144.0 318 3
NGCMN Minimum new generation capacity (KB). 新生代最小容量1536000
NGCMX Maximum new generation capacity (KB). 新生代最大容量1536000
NGC Current new generation capacity (KB). 新生代目前大小1536000
S0C Current survivor space 0 capacity (KB). 幸存者0目前大小36352
S1C Current survivor space 1 capacity (KB). 幸存者1目前大小36864
EC Current eden space capacity (KB). 伊甸园目前大小1462272
OGCMN Minimum old generation capacity (KB). 老年代最小容量2658304
OGCMX Maximum old generation capacity (KB). 老年代最大容量2658304
OGC Current old generation capacity (KB). 当前老年代大小2658304
OC Current old space capacity (KB). 2658304
PGCMN Minimum permanent generation capacity (KB). 永久代最小容量131072
PGCMX Maximum Permanent generation capacity (KB). 永久代最大容量262144
PGC Current Permanent generation capacity (KB). 永久代当前大小198144
PC Current Permanent space capacity (KB). 198144
YGC Number of Young generation GC Events. YGC次数318
FGC Number of Full GC Events. Full GC次数3
4.jstat -gc 20327 1000
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
36352.0 36864.0 27894.4 0.0 1462272.0 756577.5 2658304.0 874302.7 198144.0 91994.3 318 18.926 3 3.139 22.065
36352.0 36864.0 27894.4 0.0 1462272.0 756577.5 2658304.0 874302.7 198144.0 91994.3 318 18.926 3 3.139 22.065
5.已使用空间占比
jstat -gcutil 20327
S0 S1 E O P YGC YGCT FGC FGCT GCT
19.99 0.00 86.49 35.73 46.43 326 19.215 3 3.139 22.354