It mentions the GC algorithm and the role of each area in the heap area.
There are various types of GC algorithms themselves. The following two are the most basic.
Mark & Sweep is the standard in Java. However, this alone has the following problems, and it is actually extended and implemented.
If the unnecessary area is released repeatedly, the empty area becomes uneven and inflexible. In other words, the processing cost for creating a new object increases.
Therefore, the following algorithms are combined.
** This is why the heap area has a From area and a To area. ** **
--Mark & Sweep Mark is added in parallel in threads without stopping the Java program. --The problem is that if the state is changed before Sweep runs, there is a possibility of leakage and dust. To solve this, mark the object when it is changed (it seems to be a write barrier), stop the Java program before the mark ends and Sweep starts, and fix the marking from the marked place. do. (Serial marking)
It's called a concurrent marker sweep because it adds up this algorithm.
It uses a generational GC algorithm. Simply put, a new object is placed in the New area, GC is applied to the New area frequently, and the objects that survived after several GCs are considered to continue to survive and are placed in the Old area. An algorithm called FullGC when moving and old are accumulated. Instead of doing Full GC every time, limit the target range of GC and distribute the load of GC.
Reference: GC by generation
** This is why there are New and Old in the JVM heap area. ** **
From the contents so far, the following can be understood.
--The reason why From and To are separated in the New and Old areas is to perform copying to prevent fragmentation of the heap area.
--The reason why there are New and Old in the heap area is to limit the area targeted for GC and distribute the processing load. (The Eden area in New also exists because I want to remove the newly created object from the GC target and separate it.)
Java heap memory management mechanism
An algorithm called Garbage First Garbage Collection is coming ...? Garbage-First Garbage Collection
Recommended Posts