Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GC (Allocation Failure) VS OutOfMemoryError Exception

Tags:

java

jvm

java-8

'OutOfMemoryError': Usually, this error is thrown when there is insufficient space to allocate an object in the Java heap.

GC (Allocation Failure): Allocation Failure” means that there is an allocation request that is bigger than the available space in young generation.

Does this mean Allocation Failure will be thrown when Young generation memory is full (Minor GC) and "OutOfMemoryError" is thrown in full GC?

like image 617
user3024119 Avatar asked May 09 '17 05:05

user3024119


People also ask

What does GC allocation failure mean?

A GC allocation failure means that the garbage collector could not move objects from young gen to old gen fast enough because it does not have enough memory in old gen. This can cause application slowness.

Is GC allocation failure normal?

This 'Allocation failure' log is not an error but is a totally normal case in JVM. This is a typical GC event which causes the Java Garbage Collection process to get triggered. Garbage Collection removes dead objects, compact reclaimed memory and thus helps in freeing up memory for new object allocations.

Is GC allocation failure bad?

These 'Allocation Failures' are not an error but it is a totally normal case in the JVM. There are java logs indicating that it ran out of heap space and triggered GC. The 'Allocation Failure' happens when there is not enough space to create new objects in Young Generation.


1 Answers

These could become related as far as I can tell; but they are entirely different things.

OutOfMemory is an error you can not recover from - the JVM will die at this point.

GC (Allocation Failure): Allocation Failure is the reason why GC will kick in (and do a minor collection). At this point some things might happen, like: enough space is freed for the new allocation to fit into young generation. Or that did not happen and some objects will be promoted to the old generation. If they can't be promoted, a full GC might be triggered - and if that does not free enough space an OutOfMemory might be thrown.

like image 99
Eugene Avatar answered Oct 10 '22 19:10

Eugene