About JVM Heap space and Full GC

java

Heap space

Heap space is a dynamically allocated memory space that is divided into a new generation and an old generation in JVM. By the way, the heap space containing the loaded classes and methods was called the Permanent space, but since Java8, it has been replaced by the Metaspace and has been placed in native memory.

New generation

The New generation is further divided into the following space.

  • Eden: An created object is placed first
  • Survivor spaces * 2: Sent when Eden is full

When Eden is full, Scavenge GC discards unnecessary objects and move necessary ones to other spaces. This means that each time Eden is filled, objects shuttle between two Survivor spaces, but ones that exceed the MaxTenuringThreshold number of times are sent to the Old space instead.

Old generation

The Old generation is the area in which long-lived objects are stored. When the old area is also full, full GC runs, which checks all the objects, so other things can not be performed.

Exploring the cause of OOM that occurred in Java from GC logs and heap dumps - sambaiz-net

References

JVMとGCのしくみ

Java8のHotSpotVMからPermanent領域が消えた理由とその影響 | ギークを目指して