1. 找到进程id
ps -ef | grep java
2. 生成内存快照
jmap -dump:live,format=b,file=java-heap-dump.hprof 4028380
3. Java堆和方法区的详细信息、内存空间使用率、当前用的是哪种收集器
jmap -heap 4028380
[root@iZwz91ua0udzucg7foj0ffZ logs]# jmap -heap 4028380
Attaching to process ID 4028380, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.251-b08
using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 8589934592 (8192.0MB)
NewSize = 805306368 (768.0MB)
MaxNewSize = 805306368 (768.0MB)
OldSize = 3489660928 (3328.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 = 724828160 (691.25MB)
used = 488917664 (466.2682189941406MB)
free = 235910496 (224.98178100585938MB)
67.45290690692812% used
Eden Space:
capacity = 644349952 (614.5MB)
used = 486374072 (463.8424606323242MB)
free = 157975880 (150.65753936767578MB)
75.48290653089084% used
From Space:
capacity = 80478208 (76.75MB)
used = 2543592 (2.4257583618164062MB)
free = 77934616 (74.3242416381836MB)
3.1605972140930376% used
To Space:
capacity = 80478208 (76.75MB)
used = 0 (0.0MB)
free = 80478208 (76.75MB)
0.0% used
concurrent mark-sweep generation:
capacity = 7784628224 (7424.0MB)
used = 249085976 (237.5468978881836MB)
free = 7535542248 (7186.453102111816MB)
3.199715758192128% used
57262 interned Strings occupying 6388088 bytes.