Why does Java 8 GC logs "Allocation Failure" in young generation?
Environment
- Java 8
Issue
- Why does Java 8 GC logs
"Allocation Failure"in young generation ?
2015-06-16T13:23:09.424-0400: 1872.996: [GC (Allocation Failure) [PSYoungGen: 561821K->20572K(613376K)] 659843K->118602K(2011648K), 0.0329076 secs] [Times: user=0.04 sys=0.00, real=0.04 secs]
2015-06-16T13:31:12.042-0400: 2355.614: [GC (Allocation Failure) [PSYoungGen: 551004K->25542K(619008K)] 649034K->123580K(2017280K), 0.0774830 secs] [Times: user=0.15 sys=0.00, real=0.07 secs]
2015-06-16T13:44:20.370-0400: 3143.942: [GC (Allocation Failure) [PSYoungGen: 562630K->22931K(616960K)] 660668K->120977K(2015232K), 0.0326503 secs] [Times: user=0.06 sys=0.00, real=0.03 secs]
2015-06-16T13:58:51.005-0400: 4014.577: [GC (Allocation Failure) [PSYoungGen: 560019K->24357K(623616K)] 658065K->122411K(2021888K), 0.0500686 secs] [Times: user=0.07 sys=0.00, real=0.05 secs]
Resolution
Usually "Allocation Failure" means that there is an allocation request that is bigger than the available space in young generation and will typically be associated with a minor GC (in comparison with a Major GC, which is cleaning the Tenured space).
This is a normal cause of young garbage collection and is not typically a cause of concern. GC behaved in the same manner prior to Java 8, but GC logging previously did not log "Allocation Failure".
Root Cause
Minor GC
- Collecting garbage from the Young space is called Minor GC.
Minor GC is always triggered when the JVM is unable to allocate space for a new object, e.g. Eden is getting full. Therefore, the higher the allocation rate, the more frequently Minor GC occurs, because it is related to more objects being added to the JVM.
During a Minor GC event, Tenured Generation is effectively ignored. References from Tenured Generation to Young Generation are considered to be GC roots. References from Young Generation to Tenured Generation are simply ignored during the mark phase.
Although very fast, Minor GC does trigger stop-the-world pauses, suspending the application threads.
Major GC
- Major GC is cleaning the Old space.
Full GC
- Full GC is cleaning the entire Heap – both Young and Old spaces.
- Full GC can be trigged by a Metaspace resize, i.e. when the Metaspace cap is reached.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.