[JVM] A detailed diagram of the memory application process for new objects in the JVM heap and the four cases of the old age

Four cases of JVM aging age

1. Guarantee mechanism

When the memory size of the Survivor area is not enough to hold all the surviving objects in the next Minor GC, the guarantee mechanism will be activated, and the objects that cannot be stored in the Survivor area will be placed in the old age;

2. Large objects are placed directly into the old age

Large objects (objects with a size greater than -XX:PretenureSizeThreshold) allocate memory directly in the old generation; (only valid for Serial and ParNew collectors, invalid for Parallel Scavenge collectors)

3. Long-lived objects enter the old age

Promote the object whose age is greater than -XX:MaxTenuringThreshold to the old age; (every time the object survives in the Survivor area, its age increases by one year);

4. Dynamic age judgment

When the sum of the size of all objects of the same age in the Survivor space is greater than half of the Survivor space, objects whose age is greater than or equal to this age can directly enter the old age without reaching the default generation age.

Flowchart of requesting memory for new objects in the heap

insert image description here

Brain map download address https://gitee.com/vx202158/vx202158

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324113233&siteId=291194637