JVM internal power enhancement articles

Day02 ------JVM internal power enhancement articles

01 Combining the Eden, S0, S1 and Old areas, describe the process of creating an object? ? ?
02 How to determine an object as garbage?
03 What are the commonly used garbage collection algorithms? And what are the advantages and disadvantages? ? ?

Answer:
Eden, S0, S1 (8:1:1)
01. During the process of creating an object,
an object is created—"Enter the Eden area, the memory in the Eden area is not enough and the object is alive, use the mark-copy algorithm (special case: such as object If you can't put it in the Eden area, put it directly in the old area) copy it to the S0 area, and clear the unreachable objects in the Eden area. If the S0 area is full, the object is transferred to the S1 area (the object is switched back and forth between the S0 and S1 areas). If the object is still alive after multiple GCs (every garbage collection is still alive, count+) When count>15, then The object is placed directly in the old area.
Special case: spike project, after an object is created in the Eden area-----live and die.
An object is created and stored in the Eden area of ​​the new generation for the first time. If the memory is very large, it is directly placed in the old area;
02. Determine an object For garbage
a. Determine whether an object is garbage by reference counting method. If there is a circular reference, it will end in an endless loop.
b. Reachability analysis: If it is unreachable, it is garbage (unreachable by class loader, non-static variable, non-constant ----Uncertain)
c. Through thread sharing, it can be judged whether the object is garbage;

**=====&#

Guess you like

Origin blog.csdn.net/qq_43070471/article/details/104535006