使用 Adoptium Temurin Java 11 和 G1 GC 设置
-XX:+UseG1GC -XX:+DisableExplicitGC -verbosegc -Xlog:gc*,safepoint=debug:file=${GCFILENAME}:tags,time,uptime,level:filecount=10,filesize=10M -XX:-OmitStackTraceInFastThrow -XX:+PrintClassHistogram
我们得到这样的输出(省略每行的领先时间信息):
[info ][safepoint ] Entering safepoint region: G1CollectForAllocation
[info ][gc,start ] GC(5342) Pause Young (Prepare Mixed) (G1 Evacuation Pause)
[info ][gc,task ] GC(5342) Using 4 workers of 4 for evacuation
[info ][gc,phases ] GC(5342) Pre Evacuate Collection Set: 0.1ms
[info ][gc,phases ] GC(5342) Evacuate Collection Set: 94.8ms
[info ][gc,phases ] GC(5342) Post Evacuate Collection Set: 48.9ms
[info ][gc,phases ] GC(5342) Other: 2.7ms
[info ][gc,heap ] GC(5342) Eden regions: 1521->0(50)
[info ][gc,heap ] GC(5342) Survivor regions: 15->78(192)
[info ][gc,heap ] GC(5342) Old regions: 442->442
[info ][gc,heap ] GC(5342) Humongous regions: 214->0
[info ][gc,metaspace ] GC(5342) Metaspace: 80251K(87856K)->80251K(87856K) NonClass: 72293K(77488K)->72293K(77488K) Class: 7957K(10368K)->7957K(10368K)
[info ][gc ] GC(5342) Pause Young (Prepare Mixed) (G1 Evacuation Pause) 4382M->1040M(5120M) 146.102ms
[info ][gc,cpu ] GC(5342) User=0.56s Sys=0.01s Real=0.15s
[info ][safepoint ] Leaving safepoint region
我试图找到每行输出的解释。我发现 2016 年的一篇文章提到,仅设置 {
-Xloggc:/home/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps
} 就会给出输出行,包括以下信息:
[Eden: 12.0M(12.0M)->0.0B(14.0M) Survivors: 0.0B->2048.0K Heap: 12.6M(252.0M)->7848.3K(252.0M)]
我有更多的台词,例如:
[info ][safepoint ] Entering safepoint region: Cleanup
[info ][safepoint ] Leaving safepoint region
[info ][safepoint ] Total time for which application th
[debug][safepoint ] Safepoint synchronization initiated
[info ][safepoint ] Application time: 1.0001197 seconds
比我想看到的更多,但我想要更多字节处理/回收细节。以及对输出的一些解释(比如
Eden regions: 1521->0(50)
是什么意思?)。
有谁知道获取字节处理详细信息和解释输出行的文档的选项?谢谢你。
我尝试过 G1 日志记录调试级别和 -verbosegc。我尝试了跟踪级别,但细节太多,无法筛选和存档。
我希望看到更多类似于 Java 8 GC 输出的 G1 输出,我会得到:
par new generation total 314560K, used 279616K [0x00000000c0000000, 0x00000000d5550000, 0x00000000d5550000)
eden space 279616K, 100% used [0x00000000c0000000, 0x00000000d1110000, 0x00000000d1110000)
from space 34944K, 0% used [0x00000000d1110000, 0x00000000d1110000, 0x00000000d3330000)
to space 34944K, 0% used [0x00000000d3330000, 0x00000000d3330000, 0x00000000d5550000)
concurrent mark-sweep generation total 174784K, used 0K [0x00000000d5550000, 0x00000000e0000000, 0x0000000100000000)
Metaspace used 17658K, capacity 18464K, committed 18816K, reserved 1067008K
class space used 1931K, capacity 2067K, committed 2176K, reserved 1048576K
Desired survivor size 17891328 bytes, new threshold 15 (max 15)
- age 1: 17555944 bytes, 17555944 total
: 279616K->17269K(314560K), 0.0241802 secs] 279616K->17269K(489344K)
Desired survivor size 17891328 bytes, new threshold 15 (max 15)
- age 1: 17555944 bytes, 17555944 total
: 279616K->17269K(314560K), 0.0241802 secs] 279616K->17269K(489344K)
虽然我仍然希望每行输出都带有时间戳。
我希望增加有关使用、提交和保留字节数的日志记录详细信息。并理解新格式,因为
Eden regions: 1521->0(50)
我认为“有1521个区域,全部被回收,所以我去拥有50个区域”,但我不知道使用和回收了多少字节。
我使用正确的“内容选择器”获得了附加信息,因此我将在其他地方寻找输出解释。谢谢。