gpt4 book ai didi

java - G1 年轻 GC 不释放内存 - 空间耗尽

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:44:50 26 4
gpt4 key购买 nike

我正在使用 G1GC,jdk 1.7

Java HotSpot(TM) 64-Bit Server VM (24.79-b02) for linux-amd64 JRE (1.7.0_79-b15), built on Apr 10 2015 11:34:48 by "java_re" with gcc 4.3.0 20080428 (Red Hat 4.3.0-8)
Memory: 4k page, physical 32826020k(12590436k free), swap 33431548k(33358800k free)

CommandLine flags: -XX:AutoBoxCacheMax=3000000 -XX:+DisableExplicitGC
-XX:G1NewSizePercent=20 -XX:+HeapDumpOnOutOfMemoryError -XX:InitialHeapSize=10737418240
-XX:InitiatingHeapOccupancyPercent=70 -XX:MaxDirectMemorySize=1073741824 -XX:MaxGCPauseMillis=1000
-XX:MaxHeapSize=10737418240
-XX:-OmitStackTraceInFastThrow -XX:+PrintGC -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDetails
-XX:+PrintGCTimeStamps -XX:+UnlockExperimentalVMOptions
-XX:+UseCompressedOops -XX:+UseG1GC

大多数次要 GC 工作正常,但它仍然会启动不正常的 fullGC,大约一小时一到两次。

这是一个正常情况的young GC日志

3443.100: [GC pause (young), 0.3021260 secs]
[Parallel Time: 277.6 ms, GC Workers: 4]
[GC Worker Start (ms): Min: 3443100.5, Avg: 3443100.6, Max: 3443100.6, Diff: 0.1]
[Ext Root Scanning (ms): Min: 2.9, Avg: 3.0, Max: 3.1, Diff: 0.2, Sum: 11.9]
[Update RS (ms): Min: 33.5, Avg: 33.6, Max: 33.9, Diff: 0.4, Sum: 134.5]
[Processed Buffers: Min: 180, Avg: 204.8, Max: 227, Diff: 47, Sum: 819]
[Scan RS (ms): Min: 76.0, Avg: 76.2, Max: 76.3, Diff: 0.3, Sum: 304.9]
[Code Root Scanning (ms): Min: 0.0, Avg: 0.1, Max: 0.1, Diff: 0.1, Sum: 0.3]
[Object Copy (ms): Min: 164.4, Avg: 164.4, Max: 164.5, Diff: 0.1, Sum: 657.7]
[Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
[GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.0, Sum: 0.2]
[GC Worker Total (ms): Min: 277.3, Avg: 277.4, Max: 277.4, Diff: 0.1, Sum: 1109.5]
[GC Worker End (ms): Min: 3443377.9, Avg: 3443378.0, Max: 3443378.0, Diff: 0.0]
[Code Root Fixup: 0.2 ms]
[Code Root Migration: 0.3 ms]
[Clear CT: 2.0 ms]
[Other: 22.1 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 15.7 ms]
[Ref Enq: 0.5 ms]
[Free CSet: 3.2 ms]
[Eden: 5996.0M(5996.0M)->0.0B(5648.0M) Survivors: 148.0M->196.0M Heap: 8934.5M(10.0G)->2997.2M(10.0G)]
[Times: user=1.13 sys=0.00, real=0.30 secs]

这是fullGC之前的异常GC日志。重复了两三遍,也没有清理内存。

3482.422: [GC pause (young) (to-space exhausted), 3.4878580 secs]
[Parallel Time: 1640.5 ms, GC Workers: 4]
[GC Worker Start (ms): Min: 3482421.8, Avg: 3482422.4, Max: 3482424.0, Diff: 2.2]
[Ext Root Scanning (ms): Min: 2.1, Avg: 3.2, Max: 3.8, Diff: 1.7, Sum: 12.6]
[Update RS (ms): Min: 104.8, Avg: 105.2, Max: 105.6, Diff: 0.8, Sum: 421.0]
[Processed Buffers: Min: 201, Avg: 221.2, Max: 236, Diff: 35, Sum: 885]
[Scan RS (ms): Min: 75.1, Avg: 75.2, Max: 75.3, Diff: 0.1, Sum: 300.8]
[Code Root Scanning (ms): Min: 0.0, Avg: 0.1, Max: 0.1, Diff: 0.1, Sum: 0.2]
[Object Copy (ms): Min: 1455.9, Avg: 1456.1, Max: 1456.2, Diff: 0.3, Sum: 5824.2]
[Termination (ms): Min: 0.0, Avg: 0.1, Max: 0.2, Diff: 0.2, Sum: 0.4]
[GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
[GC Worker Total (ms): Min: 1638.2, Avg: 1639.8, Max: 1640.4, Diff: 2.2, Sum: 6559.3]
[GC Worker End (ms): Min: 3484062.2, Avg: 3484062.2, Max: 3484062.2, Diff: 0.0]
[Code Root Fixup: 0.2 ms]
[Code Root Migration: 0.5 ms]
[Clear CT: 2.0 ms]
[Other: 1844.7 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 60.1 ms]
[Ref Enq: 0.5 ms]
[Free CSet: 1.2 ms]
[Eden: 5648.0M(5648.0M)->0.0B(1876.0M) Survivors: 196.0M->172.0M Heap: 9441.9M(10.0G)->9352.3M(10.0G)]
[Times: user=9.29 sys=0.05, real=3.49 secs]

然后开始了fullGC

3490.812: [Full GC 9626M->1879M(10G), 7.6059670 secs]
[Eden: 0.0B(2048.0M)->0.0B(6144.0M) Survivors: 0.0B->0.0B Heap: 9626.3M(10.0G)->1879.5M(10.0G)], [Perm: 33901K->33901K(36864K)]
[Times: user=10.24 sys=0.00, real=7.61 secs]

为什么最后一次youngGC没有清理任何内存?

最佳答案

从收集开始消息的 to-space exhausted 部分可以看出,您正在遭受撤离失败。

当您的堆上没有足够的可用空间来提升存活或提升的对象(或两者)并且堆无法进一步扩展时,就会发生这种情况。

Monica Beckwith 在 Tips for Tuning the Garbage First Garbage Collector 中写道:

For G1 GC, an evacuation failure is very expensive -

  • For successfully copied objects, G1 needs to update the references and the regions have to be tenured.
  • For unsuccessfully copied objects, G1 will self-forward them and tenure the regions in place.

往往G1在被迫做这些操作时跟不上分配速度,最终会因为分配失败而被迫进行Full GC。这可能就是为什么在几次疏散失败后您会看到完整的 GC。

Monica 还在 Garbage First Garbage Collector Tuning 中写下了可能的解决方案

  • Increase the value of the -XX:G1ReservePercent option (and the total heap accordingly) to increase the amount of reserve memory for "to-space".

  • Start the marking cycle earlier by reducing the -XX:InitiatingHeapOccupancyPercent.

  • You can also increase the value of the -XX:ConcGCThreads option to increase the number of parallel marking threads.

另外,增加堆是降低疏散失败可能性的另一种选择。

关于java - G1 年轻 GC 不释放内存 - 空间耗尽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30796111/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com