1.找到java进程
ps -ef|grep java
2. jmap -heap pid:输出堆内存设置和使用情况
jmap -heap pid
3.输出以下内容
[root@ecs-4d56 ~]# jmap -heap 1093
Attaching to process ID 1093, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.191-b12
using parallel threads in the new generation.
using thread-local object allocation.
Mark Sweep Compact GC
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 7516192768 (7168.0MB)
NewSize = 4294967296 (4096.0MB)
MaxNewSize = 4294967296 (4096.0MB)
OldSize = 3221225472 (3072.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 = 3865509888 (3686.4375MB)
used = 2144772272 (2045.4142303466797MB)
free = 1720737616 (1641.0232696533203MB)
55.48484764346824% used
Eden Space:
capacity = 3436052480 (3276.875MB)
used = 2092850688 (1995.89794921875MB)
free = 1343201792 (1280.97705078125MB)
60.90857750810605% used
From Space:
capacity = 429457408 (409.5625MB)
used = 51921584 (49.51628112792969MB)
free = 377535824 (360.0462188720703MB)
12.090042698716237% used
To Space:
capacity = 429457408 (409.5625MB)
used = 0 (0.0MB)
free = 429457408 (409.5625MB)
0.0% used
tenured generation:
capacity = 3221225472 (3072.0MB)
used = 320920464 (306.05360412597656MB)
free = 2900305008 (2765.9463958740234MB)
9.9626824259758% used
40493 interned Strings occupying 4612712 bytes.
4.当前系统JVM内的Eden、Survivor、老年代的内存使用情况,还有youngGC和 full GC的执行次数以及耗时。
jstat -gc pid 2000
输出以下信息
各字段解释