Does the major garbage collection collect an object from both generations?

As you know, when an object is created, it is stored in the eden space inside the new generation, then moves to the remaining spaces (if it is alive), and then to the old generation.

My question is: does the main garbage collection make clean objects of the old generation or does the new and old generation clean like?

+4
source share
3 answers

There are three types of collections in HotSpot for Parallel and Concurrent Mark Sweep. There is a small collection that represents only paradise or paradise and surviving areas. A complete collection, which is everything, and a parallel collection, which is only the old generation. This is not the main collection. The term complete collection is more often used and more meaningful in meaning.

The G1 team has two generations of young and old, but only one type of collection and has relatively continuous collections. It can clear only 1 MB or potentially all memory.

JVM Azul is purely parallel across all generations.

+4
source

For JVM HotSpot:

  • Mark Sweep Compact collectors (Serial, Parallel scavenge, Parallel old) collect both young and old during the old collection. If there is a case with insufficient size of the old space, this collector can switch to non-generation mode (it is effective to make only complete collections).

  • The parallel Mark Sweep collection only collects old space. But if the failure match fails, it returns to Stop-The-World Mark Sweep Compact Full and collects both spaces.

  • G1 has a young collection and an old collection. The young collection collects only young space. An old collection usually collects part of the old space (G1 is incremental). If the incremental mode fails, it returns to Full GC, which collects all the spaces.

See the GC switch cheatsheet for JVM configuration options.

+1
source

When the young generation is full, the collection of the young generation (sometimes called a small assembly) of that generation alone is executed. When an old or permanent generation is filled, the so-called complete collection (sometimes called the main collection) is usually made. That is, all generations are going.

+1
source

All Articles