查看JVM相关信息

1、查看堆内存信息

1
2
$ jps #拿到pid 
$ jmap -heap pid #查看堆内存信息

使用jps拿到进程ID

获取进程ID,使用jmap获取堆内存信息

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
C:\Users\ASUS>jmap -heap 17044
Attaching to process ID 17044, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.51-b03

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

Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 3183476736 (3036.0MB)
NewSize = 66060288 (63.0MB)
MaxNewSize = 1061158912 (1012.0MB)
OldSize = 133169152 (127.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 = 444071936 (423.5MB)
used = 231835648 (221.095703125MB)
free = 212236288 (202.404296875MB)
52.2067775974026% used
From Space:
capacity = 15728640 (15.0MB)
used = 15658016 (14.932647705078125MB)
free = 70624 (0.067352294921875MB)
99.55098470052083% used
To Space:
capacity = 18874368 (18.0MB)
used = 0 (0.0MB)
free = 18874368 (18.0MB)
0.0% used
PS Old Generation
capacity = 93847552 (89.5MB)
used = 24636544 (23.4952392578125MB)
free = 69211008 (66.0047607421875MB)
26.251663975209496% used

23843 interned Strings occupying 2936440 bytes.

2、查看jvm参数

1
$ jinfo -flags pid

3、查看jvm的gc情况

1
$ jstat -gc pid 5000 10 #每5s输出一次,执行10次

4、查看GC参数

1
2
$ java -XX:+PrintFlagsInitial #查看gc参数 
$ java -XX:+PrintFlagsFinal #查看运行时gc参数


查看JVM相关信息
https://river106.cn/posts/8f136c71.html
作者
river106
发布于
2020年7月12日
许可协议