Java GC(分配失败)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28342736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java GC (Allocation Failure)
提问by user3644708
Why always "GC (Allocation Failure)"?
为什么总是“GC(分配失败)”?
Java HotSpot(TM) 64-Bit Server VM (25.25-b02) for linux-amd64 JRE (1.8.0_25-b17),
用于 linux-amd64 JRE ( 1.8.0_25-b17) 的Java HotSpot(TM) 64 位服务器 VM (25.25- b02),
CommandLine flags:
-XX:CMSInitiatingOccupancyFraction=60
-XX:GCLogFileSize=10485760
-XX:+HeapDumpOnOutOfMemoryError
-XX:InitialHeapSize=32212254720
-XX:MaxHeapSize=32212254720
-XX:NewRatio=10
-XX:OldPLABSize=16
-XX:ParallelGCThreads=4
-XX:+PrintGC
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintStringTableStatistics
-XX:+PrintTenuringDistribution
-XX:StringTableSize=1000003
-XX:SurvivorRatio=4
-XX:TargetSurvivorRatio=50
-XX:+UseCompressedClassPointers
-XX:+UseCompressedOops
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
27.329: [GC (Allocation Failure) 27.329: [ParNew
Desired survivor size 44728320 bytes, new threshold 15 (max 15)
- age 1: 16885304 bytes, 16885304 total
: 349568K->16618K(436928K), 0.2069129 secs] 349568K->16618K(31369920K), 0.2070712 secs] [Times: user=0.78 sys=0.04, real=0.21 secs]
28.210: [GC (Allocation Failure) 28.210: [ParNew
Desired survivor size 44728320 bytes, new threshold 15 (max 15)
- age 1: 28866504 bytes, 28866504 total
- age 2: 12582536 bytes, 41449040 total
: 366186K->47987K(436928K), 0.2144807 secs] 366186K->47987K(31369920K), 0.2146024 secs] [Times: user=0.84 sys=0.01, real=0.22 secs]
29.037: [GC (Allocation Failure) 29.038: [ParNew
Desired survivor size 44728320 bytes, new threshold 2 (max 15)
- age 1: 28443488 bytes, 28443488 total
- age 2: 28386624 bytes, 56830112 total
- age 3: 12579928 bytes, 69410040 total
: 397555K->76018K(436928K), 0.2357352 secs] 397555K->76018K(31369920K), 0.2358535 secs] [Times: user=0.93 sys=0.01, real=0.23 secs]
采纳答案by Alexey Ragozin
"Allocation Failure" is a cause of GC cycle to kick in.
“分配失败”是 GC 循环启动的原因。
"Allocation Failure" means that no more space left in Eden to allocate object. So, it is normal cause of young GC.
“分配失败”意味着 Eden 中没有更多空间可以分配对象。所以,这是年轻GC的正常原因。
Older JVM were not printing GC cause for minor GC cycles.
较旧的 JVM 不打印次要 GC 周期的 GC 原因。
"Allocation Failure" is almost only possible cause for minor GC. Another reason for minor GC to kick could be CMS remark phase (if +XX:+ScavengeBeforeRemark
is enabled).
“分配失败”几乎是小 GC 的唯一可能原因。次要 GC 启动的另一个原因可能是 CMS 备注阶段(如果+XX:+ScavengeBeforeRemark
已启用)。
回答by Hatter Bush
When use CMS GC in jdk1.8 will appeare this error, i change the G1 Gc solve this problem.
在 jdk1.8 中使用 CMS GC 时会出现这个错误,我换了 G1 Gc 解决了这个问题。
-Xss512k -Xms6g -Xmx6g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:InitiatingHeapOccupancyPercent=70 -XX:NewRatio=1 -XX:SurvivorRatio=6 -XX:G1ReservePercent=10 -XX:G1HeapRegionSize=32m -XX:ConcGCThreads=6 -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps
回答by Kamal Rathod
"Allocation Failure" is cause of GC to kick is not correct. It is an outcome of GC operation.
“分配失败”是 GC 踢不正确的原因。它是 GC 操作的结果。
GC kicks in when there is no space to allocate( depending on region minor or major GC is performed). Once GC is performed if space is freed good enough, but if there is not enough size it fails. Allocation Failure is one such failure. Below document have good explanation https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/g1_gc.html
GC 在没有空间分配时启动(取决于执行区域次要或主要 GC)。一旦 GC 被释放,如果空间足够好,但如果没有足够的空间,它就会失败。分配失败就是这样一种失败。下面的文档有很好的解释 https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/g1_gc.html