0%

JVM相关命令

查看JVM相关的信息。

jinfo [option] <pid>

查看JVM使用的哪个垃圾回收器

jinfo -flags <pid>

1
2
3
4
5
6
7
8
# jinfo -flags 58256
Attaching to process ID 58256, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.212-b10
Non-default VM flags: -XX:CICompilerCount=4 -XX:InitialHeapSize=264241152 -XX:MaxHeapSize=4200595456
-XX:MaxNewSize=1399848960 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=88080384 -XX:OldSize=176160768
-XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC

可以看出是使用的 UseParallelGC

通过如下命令也可以印证。

1
2
# jinfo -flag UseParallelGC 58256
-XX:+UseParallelGC

查看类加载的信息

1
2
3
4
5
6
7
8
9
# jstat -class 58256 1000 10
Loaded Bytes Unloaded Bytes Time
14582 26192.0 1 0.9 23.92
14582 26192.0 1 0.9 23.92
14582 26192.0 1 0.9 23.92
14582 26192.0 1 0.9 23.92
14582 26192.0 1 0.9 23.92
14582 26192.0 1 0.9 23.92
14582 26192.0 1 0.9 23.92

查看垃圾回收器的信息

1
2
3
4
5
6
7
8
# jstat -gc 58256 1000 10
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
28160.0 10240.0 0.0 9808.1 597504.0 430347.2 251904.0 69700.9 78612.0 74904.0 10300.0 9577.3 17 0.643 3 1.166 1.809
28160.0 10240.0 0.0 9808.1 597504.0 430347.2 251904.0 69700.9 78612.0 74904.0 10300.0 9577.3 17 0.643 3 1.166 1.809
28160.0 10240.0 0.0 9808.1 597504.0 430347.2 251904.0 69700.9 78612.0 74904.0 10300.0 9577.3 17 0.643 3 1.166 1.809
28160.0 10240.0 0.0 9808.1 597504.0 430347.2 251904.0 69700.9 78612.0 74904.0 10300.0 9577.3 17 0.643 3 1.166 1.809
28160.0 10240.0 0.0 9808.1 597504.0 430347.2 251904.0 69700.9 78612.0 74904.0 10300.0 9577.3 17 0.643 3 1.166 1.809
28160.0 10240.0 0.0 9808.1 597504.0 430347.2 251904.0 69700.9 78612.0 74904.0 10300.0 9577.3 17 0.643 3 1.166 1.809

查看是否有死锁

1
# jstack 58256

查看堆内存数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# jmap -heap 58256
Attaching to process ID 58256, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.212-b10

using thread-local object allocation.
Parallel GC with 8 thread(s)

Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 4200595456 (4006.0MB)
NewSize = 88080384 (84.0MB)
MaxNewSize = 1399848960 (1335.0MB)
OldSize = 176160768 (168.0MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
capacity = 589299712 (562.0MB)
used = 93162144 (88.84634399414062MB)
free = 496137568 (473.1536560058594MB)
15.808958006074844% used
From Space:
capacity = 10485760 (10.0MB)
used = 10174544 (9.703201293945312MB)
free = 311216 (0.2967987060546875MB)
97.03201293945312% used
To Space:
capacity = 30408704 (29.0MB)
used = 0 (0.0MB)
free = 30408704 (29.0MB)
0.0% used
PS Old Generation
capacity = 257949696 (246.0MB)
used = 71381888 (68.0750732421875MB)
free = 186567808 (177.9249267578125MB)
27.672794000889226% used

29817 interned Strings occupying 3078576 bytes.