简体   繁体   English

Java GC(分配失败)

[英]Java GC (Allocation Failure)

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]

"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. “分配失败”意味着 Eden 中没有更多空间可以分配对象。 So, it is normal cause of young GC.所以,这是年轻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. “分配失败”几乎是小 GC 的唯一可能原因。 Another reason for minor GC to kick could be CMS remark phase (if +XX:+ScavengeBeforeRemark is enabled). Minor GC 启动的另一个原因可能是 CMS 注释阶段(如果启用了+XX:+ScavengeBeforeRemark )。

"Allocation Failure" is cause of GC to kick is not correct. “分配失败”是 GC 踢不正确的原因。 It is an outcome of GC operation.它是 GC 操作的结果。

GC kicks in when there is no space to allocate( depending on region minor or major GC is performed). GC 在没有空间分配时启动(取决于执行区域次要或主要 GC)。 Once GC is performed if space is freed good enough, but if there is not enough size it fails.一旦 GC 被释放,如果空间足够好,但如果没有足够的空间,它就会失败。 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下面的文档有很好的解释https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/g1_gc.html

在 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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM