我正在使用java8u31
(oracle)以及以下GC日志记录选项
-XX:GCLogFileSize=20971520 -XX:NumberOfGCLogFiles=5 -XX:+PrintGC
-XX:+PrintGCApplicationStoppedTime -XX:+PrintGCCause -XX:+PrintGCDateStamps
-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:-PrintTenuringDistribution
-XX:+UseG1GC -XX:+UseGCLogFileRotation
我的GC日志看起来像
2015-08-06T09:44:02.486-0400: 1085394.129: Total time for which application threads were stopped: 0.0003136 seconds
2015-08-06T09:44:02.638-0400: 1085394.281: [GC pause (G1 Evacuation Pause) (young), 0.0354571 secs]
[Parallel Time: 3.0 ms, GC Workers: 23]
[GC Worker Start (ms): Min: 1085394281.2, Avg: 1085394281.3, Max: 1085394281.5, Diff: 0.3]
[Ext Root Scanning (ms): Min: 0.4, Avg: 0.5, Max: 0.9, Diff: 0.6, Sum: 11.4]
[Update RS (ms): Min: 0.0, Avg: 0.2, Max: 0.4, Diff: 0.4, Sum: 4.7]
[Processed Buffers: Min: 0, Avg: 2.3, Max: 5, Diff: 5, Sum: 54]
[Scan RS (ms): Min: 0.0, Avg: 0.1, Max: 0.2, Diff: 0.2, Sum: 2.2]
[Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[Object Copy (ms): Min: 1.7, Avg: 1.7, Max: 1.8, Diff: 0.1, Sum: 40.2]
[Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.6]
[GC Worker Other (ms): Min: 0.0, Avg: 0.1, Max: 0.2, Diff: 0.2, Sum: 1.8]
[GC Worker Total (ms): Min: 2.5, Avg: 2.6, Max: 2.8, Diff: 0.3, Sum: 60.9]
[GC Worker End (ms): Min: 1085394283.9, Avg: 1085394284.0, Max: 1085394284.1, Diff: 0.2]
[Code Root Fixup: 0.1 ms]
[Code Root Migration: 0.1 ms]
[Code Root Purge: 0.0 ms]
[Clear CT: 0.4 ms]
[Other: 31.9 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 30.1 ms]
[Ref Enq: 0.1 ms]
[Redirty Cards: 0.0 ms]
[Free CSet: 0.7 ms]
[Eden: 610.0M(610.0M)->0.0B(606.0M) Survivors: 4096.0K->8192.0K Heap: 892.9M(1024.0M)->287.6M(1024.0M)]
[Times: user=0.10 sys=0.01, real=0.03 secs]
2015-08-06T09:44:02.673-0400: 1085394.317: Total time for which application threads were stopped: 0.0359503 seconds
2015-08-06T09:44:07.515-0400: 1085399.158: Total time for which application threads were stopped: 0.0002921 seconds
这只是一个摘录,对于任何GC Pause
(年轻或混合),我都不知道导致GC的原因。当我使用CMS
时,它会提供GC原因,例如以下是使用CMS
2015-08-09T15:15:01.665-0400: 1364453.068: [Full GC (System.gc()) 1364453.068: [CMS: 44751K->44753K(537408K), 0.0816661 secs] 135985K->44753K(920832K), [Metaspace: 37944K->37944K(1083392K)], 0.0818386 secs] [Times: user=0.08 sys=0.00, real=0.08 secs]
答案 0 :(得分:0)
(G1撤离暂停)(年轻)
这就是原因。伊甸园空间已经填满,必须收集(撤离)。
偶尔可能会看到其他的(混合,元空间充分,大量分配......),但年轻的收藏是最常见的停顿。