我是新來的G1垃圾收集,但我有一個堆的最大26G,初始大小10G,它的當前大小是26G與15G使用。G1垃圾收集器花費大部分時間在Ref Proc
我有GC日誌功能使用以下參數:
-XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -verbose:gc -Xloggc:
當我檢查出我的垃圾收集垃圾收集日誌,我發現我的Ref Proc
似乎採取的時間最長。我指定了-XX:MaxGCPauseMillis=1000
,我的GC時間接近此值,但對我而言,Ref Proc
仍然運行很長時間。我想知道是否有辦法縮短這個時間?
摘錄我的GC日誌:
[GC pause (young)
Desired survivor size 335544320 bytes, new threshold 15 (max 15)
- age 1: 18542272 bytes, 18542272 total
- age 2: 1752016 bytes, 20294288 total
- age 3: 1083928 bytes, 21378216 total
- age 4: 1078592 bytes, 22456808 total
- age 5: 854640 bytes, 23311448 total
- age 6: 549048 bytes, 23860496 total
- age 7: 1372744 bytes, 25233240 total
- age 8: 623048 bytes, 25856288 total
- age 9: 909984 bytes, 26766272 total
- age 10: 930072 bytes, 27696344 total
- age 11: 928088 bytes, 28624432 total
- age 12: 1053440 bytes, 29677872 total
- age 13: 553512 bytes, 30231384 total
- age 14: 787592 bytes, 31018976 total
- age 15: 985216 bytes, 32004192 total
, 1.22150400 secs]
[Parallel Time: 176.4 ms]
[GC Worker Start (ms): 209376973.5 209376973.6 209376973.6 209376973.6 209376973.7 209376973.7 209376973.7 209376973.8 209376973.8 209376973.8 209376973.8 209376973.9 209376973.9 209376974.0 209376974.0 209376974.0 209376974.0 209376974.1 209376974.1 209376974.1 209376974.1 209376974.2 209376974.2
Avg: 209376973.9, Min: 209376973.5, Max: 209376974.2, Diff: 0.7]
[Ext Root Scanning (ms): 2.2 2.0 2.2 1.5 36.8 2.2 3.6 1.6 1.6 1.6 1.7 2.2 1.7 1.5 1.5 1.5 1.5 1.8 1.7 1.6 1.3 1.6 1.7
Avg: 3.3, Min: 1.3, Max: 36.8, Diff: 35.5]
[Update RS (ms): 13.4 14.0 13.2 14.1 0.0 13.2 12.0 13.7 14.1 13.7 13.7 13.0 13.6 13.7 14.0 13.8 13.7 13.2 13.5 13.8 13.8 13.3 13.3
Avg: 13.0, Min: 0.0, Max: 14.1, Diff: 14.1]
[Processed Buffers : 8 4 16 6 0 11 10 9 14 8 8 11 15 5 7 7 13 16 9 6 12 7 13
Sum: 215, Avg: 9, Min: 0, Max: 16, Diff: 16]
[Scan RS (ms): 0.3 0.0 0.4 0.0 0.2 0.3 0.2 0.3 0.0 0.3 0.3 0.3 0.3 0.2 0.0 0.3 0.3 0.4 0.2 0.0 0.3 0.3 0.3
Avg: 0.2, Min: 0.0, Max: 0.4, Diff: 0.3]
[Object Copy (ms): 151.2 150.7 151.0 150.9 130.3 151.0 150.9 150.3 151.0 150.5 151.5 150.5 151.2 151.6 151.5 151.0 151.4 150.8 150.2 150.3 151.2 150.2 151.3
Avg: 150.0, Min: 130.3, Max: 151.6, Diff: 21.2]
[Termination (ms): 4.5 4.8 4.7 4.9 4.2 4.7 4.7 5.4 4.6 5.2 4.2 5.2 4.5 4.1 4.1 4.6 4.2 4.8 5.5 5.2 4.5 5.5 4.4
Avg: 4.7, Min: 4.1, Max: 5.5, Diff: 1.4]
[Termination Attempts : 2171 2328 2294 2328 2003 2294 2274 2497 2232 2498 1970 2481 2191 2035 2006 2287 2007 2320 2640 2554 2243 2532 2216
Sum: 52401, Avg: 2278, Min: 1970, Max: 2640, Diff: 670]
[GC Worker End (ms): 209377145.9 209377145.2 209377145.8 209377145.5 209377145.3 209377145.8 209377145.9 209377145.7 209377145.8 209377145.2 209377145.4 209377145.6 209377145.2 209377145.2 209377145.2 209377145.8 209377145.9 209377145.4 209377145.7 209377145.6 209377145.2 209377145.6 209377146.0
Avg: 209377145.6, Min: 209377145.2, Max: 209377146.0, Diff: 0.9]
[GC Worker (ms): 172.4 171.6 172.2 171.9 171.7 172.1 172.2 171.9 172.0 171.3 171.5 171.8 171.3 171.2 171.2 171.9 171.9 171.4 171.6 171.5 171.0 171.4 171.8
Avg: 171.7, Min: 171.0, Max: 172.4, Diff: 1.3]
[GC Worker Other (ms): 4.8 4.8 4.8 4.9 4.9 4.9 4.9 5.0 5.0 5.1 5.1 5.1 5.2 5.2 5.2 5.2 5.3 5.3 5.3 5.4 5.4 5.4 5.5
Avg: 5.1, Min: 4.8, Max: 5.5, Diff: 0.7]
[Clear CT: 1.9 ms]
[Other: 1043.2 ms]
[Choose CSet: 0.1 ms]
[Ref Proc: 1029.7 ms]
[Ref Enq: 5.5 ms]
[Free CSet: 6.4 ms]
[Eden: 4660M(4660M)->0B(4680M) Survivors: 460M->440M Heap: 15178M(25600M)->10501M(25600M)]
[Times: user=4.98 sys=0.00, real=1.22 secs]
我沒有明確使用弱/軟引用,只是說出我的對象沒有實力,我相信使它強大。現在我有除了內存和G1以外的所有東西的默認JVM參數,所以我的伊甸園大小是我的老一代的一些%。你說它看起來像我有很多對象從新 - >舊,然後他們得到不久後從老一代中刪除? – Nicholas
@Nicholas我在說,你或你正在使用的圖書館有很多WeakReference或SoftReferences。我也在說你會遇到很多在舊空間裏死去的物體,但我懷疑這不是你最主要的問題。 –
好的,謝謝你的澄清。我將研究我們正在使用的圖書館,他們可能以這種方式創建對象。 – Nicholas