求助>想问一下 g1 触发Full GC (Allocation Failure)的原因>
3回复
1月前

想问一下 g1 触发Full GC (Allocation Failure)的原因



想问一下 g1 触发Full GC (Allocation Failure)的原因
配置的内存是18GB. 但是堆到了13 14GB就开始触发FGC.是晋升老年代失败吗,可是从日志看老年代还有几个G的可用空间.

dsegc.log

689 阅读
请先登录,再评论

回复列表

https://a.perfma.net/img/2382850
ferdi1月前

G1会在一种情况下提前触发fullgc,就是G1在执行中判断并发收集无法满足设定的延迟需求的时候会提前触发fullgc,详细的可以看下面的文档 Observing Full Garbage Collections 解决方法文中也说到了,减少对象的产生,加大GC线程数,增大堆等等,具体采用什么方式最有效得看具体情况~

2
hui3周前
回复 ferdi:

后面使用java11跑,一样程序,一样参数,发现Humongous region 数量达到了 847个, full gc也没有回收. 然而我们region size配置的是16MB.本来总得region 数量也就1152. 于是每一次年轻代回收,都没有足够的region.存放存活对象. 都放到老年代去了. 然后mixed回收对象时,因为收益达不到10%,因此也没有回收老年代. 最终直接引发full gc

回复
hui1月前

我自己看触发full gc前的 一次ygc,觉得是对象晋升old 的时候,或者需要在old上分配对象失败了.但是我们这个region size是特意设置过的16MB. 觉得应该还是对象晋升引起. 只是old gen 还有不少空间,怎么就晋升失败了. 不知道我的理解有没有错.

138.974: [GC pause (G1 Evacuation Pause) (young) (to-space exhausted), 0.0356118 secs]
   [Parallel Time: 4.5 ms, GC Workers: 28]
      [GC Worker Start (ms): Min: 138974.9, Avg: 138975.3, Max: 138975.9, Diff: 1.0]
      [Ext Root Scanning (ms): Min: 0.0, Avg: 0.3, Max: 0.6, Diff: 0.6, Sum: 8.0]
      [Update RS (ms): Min: 0.0, Avg: 0.3, Max: 1.1, Diff: 1.1, Sum: 7.3]
         [Processed Buffers: Min: 0, Avg: 2.8, Max: 10, Diff: 10, Sum: 78]
      [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.2, Diff: 0.2, Sum: 1.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: 2.4, Max: 3.0, Diff: 1.3, Sum: 67.9]
      [Termination (ms): Min: 0.0, Avg: 0.5, Max: 0.8, Diff: 0.8, Sum: 14.0]
         [Termination Attempts: Min: 1, Avg: 1.0, Max: 1, Diff: 0, Sum: 28]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.4]
      [GC Worker Total (ms): Min: 2.9, Avg: 3.5, Max: 4.1, Diff: 1.2, Sum: 98.8]
      [GC Worker End (ms): Min: 138978.7, Avg: 138978.8, Max: 138979.0, Diff: 0.3]
   [Code Root Fixup: 0.1 ms]
   [Code Root Purge: 0.0 ms]
   [Clear CT: 0.8 ms]
   [Other: 30.1 ms]
      [Evacuation Failure: 26.8 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 1.2 ms]
      [Ref Enq: 0.0 ms]
      [Redirty Cards: 1.2 ms]
      [Humongous Register: 0.7 ms]
      [Humongous Reclaim: 0.1 ms]
      [Free CSet: 0.0 ms]
   [Eden: 80.0M(784.0M)->0.0B(912.0M) Survivors: 128.0M->0.0B Heap: 13.5G(18.0G)->13.5G(18.0G)]
 [Times: user=0.16 sys=0.01, real=0.04 secs]
139.010: [Full GC (Allocation Failure)  13G->10G(18G), 0.3422904 secs]
   [Eden: 0.0B(912.0M)->0.0B(912.0M) Survivors: 0.0B->0.0B Heap: 13.5G(18.0G)->10.9G(18.0G)], [Metaspace: 21184K->21184K(1069056K)]