ZGC

背景

昨天临下班同事贴了张top的图,在测试过程中进程 VIRT 项异常的高

测试机器是新到手的 Rocky Linux release 8.5 kernel 4.18,刚好我也有这台机器的权限,就爬上去看一眼。

step….s

1. top

  • 和同事截图一致,VIRT 200G+,基于之前的印象第一感觉是不是程序线程开多了,一个线程 64M
  • 拿到 processId,继续检查

2. cat /proc/9432/status

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
Name:   java
Umask: 0022
State: S (sleeping)
Tgid: 9432
Ngid: 0
Pid: 9432
VmPeak: 212897896 kB
VmSize: 212884428 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 11635800 kB
VmRSS: 11635800 kB
RssAnon: 613024 kB
RssFile: 24524 kB
RssShmem: 10998252 kB
VmData: 817140 kB
VmStk: 132 kB
VmExe: 4 kB
VmLib: 23368 kB
VmPTE: 24832 kB
VmSwap: 0 kB
HugetlbPages: 0 kB
Threads: 84
...
...
  • 84个线程,算下来也不该这么大的占用

3. pmap -x 9432 or cat /proc/9432/maps

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@localhost xxxxx]# cat /proc/9432/stat
9432 (java) S 1 9424 7983 34816 9886 1077952512 2169485 0 48 0 47084 41243 0 0 20 0 85 0 2341714 217993654272 3035148 18446744073709551615 93986510553088 93986510556840 140733418035776 0 0 0 0 3 16800972 0 0 0 17 2 0 0 5 0 0 93986510564600 0733418041311 0
[root@localhost xxxxx]# cat /proc/9432/maps
800000000-800003000 rwxp 00001000 08:03 67125341 /opt/jdk-15.0.1/lib/server/classes_nocoops.jsa
800003000-8003e6000 rw-p 00004000 08:03 67125341 /opt/jdk-15.0.1/lib/server/classes_nocoops.jsa
8003e6000-800b23000 r--p 003e7000 08:03 67125341 /opt/jdk-15.0.1/lib/server/classes_nocoops.jsa
800b23000-800b24000 ---p 00000000 00:00 0
800b24000-8014e4000 rw-p 00000000 00:00 0
8014e4000-810324000 ---p 00000000 00:00 0
40000000000-40100000000 rw-s 00000000 00:01 423464 /memfd:java_heap (deleted)
40100000000-41000000000 ---p 00000000 00:00 0
80000000000-80100000000 rw-s 00000000 00:01 423464 /memfd:java_heap (deleted)
80100000000-81000000000 ---p 00000000 00:00 0
100000000000-100100000000 rw-s 00000000 00:01 423464 /memfd:java_heap (deleted)
100100000000-101000000000 ---p 00000000 00:00 0
557af0934000-557af0935000 r-xp 00000000 08:03 67125607 /opt/jdk-15.0.1/bin/java
557af0936000-557af0937000 r--p 00001000 08:03 67125607 /opt/jdk-15.0.1/bin/java
557af0937000-557af0938000 rw-p 00002000 08:03 67125607 /opt/jdk-15.0.1/bin/java
557af12e5000-557af19ed000 rw-p 00000000 00:00 0 [heap]
...
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@localhost qa_winter-game-battle]# pmap -x 9432
9432: java -Dfile.encoding=UTF-8 -Denv=dev -Dapollo.cluster=dev -Deureka.client.registerWithEureka=false -Xms4g -Xmx4g -XX:+UseZGC -XX:MaxMetaspaceSize=256m -XX:MaxDirectMemorySize=1g -Xlog:gc*:./logs/gc.log -ea -jar game-battle.jar
Address Kbytes RSS Dirty Mode Mapping
0000000800000000 12 8 4 rwx-- classes_nocoops.jsa
0000000800003000 3980 1760 20 rw--- classes_nocoops.jsa
00000008003e6000 7412 0 0 r---- classes_nocoops.jsa
0000000800b23000 4 0 0 ----- [ anon ]
0000000800b24000 9984 9632 9040 rw--- [ anon ]
00000008014e4000 243968 0 0 ----- [ anon ]
0000040000000000 4194304 3407192 3407192 rw-s- memfd:java_heap (deleted)
0000040100000000 62914560 0 0 ----- [ anon ]
0000080000000000 4194304 3357220 3357220 rw-s- memfd:java_heap (deleted)
0000080100000000 62914560 0 0 ----- [ anon ]
0000100000000000 4194304 3356636 3356636 rw-s- memfd:java_heap (deleted)
0000100100000000 62914560 0 0 ----- [ anon ]
0000557af0934000 4 0 0 r-x-- java
0000557af0936000 4 0 0 r---- java
0000557af0937000 4 0 0 rw--- java
0000557af12e5000 38776 21236 21232 rw--- [ anon ]
...
...
  • 看到了三块很大的分配, 加起来 180G;这块内存的位置看起来更像是进程启动所需的堆空间
    Address Kbytes RSS Dirty Mode Mapping
    0000100100000000 62914560 0 0 ----- [ anon ]
    0000100100000000 62914560 0 0 ----- [ anon ]
    0000100100000000 62914560 0 0 ----- [ anon ]

  • 这里也注意到,程序启动特别设置了 +UseZGC

------ 本文结束 ------
------ 版权声明:转载请注明出处 ------