When does the object enter the old age


(1) When the object is first created, it will be placed in the eden area of ​​the new generation. If there is no GC intervention, it will always be in the eden area. After GC, it may enter the survivor area or the old generation.

(2) When the age of the object reaches a certain size, it will leave the young generation and enter the old generation. The age of the object is determined by the number of GCs

-XX:MaxTenuringThreshold=n The objects of the new generation can be promoted to the old generation after at most n times of GC, but it is not a necessary condition   

-XX:TargetSurvivorRatio=n is used to set the target usage rate of the Survivor area, that is, when the usage rate of the survivor area exceeds this value after GC, a smaller age may be used as the promotion age

(3) In addition to age, the size of the object will also affect the promotion of the object. If the size of the object is too large, the new generation cannot accommodate the object

-XX:PretenureSizeThreshold If the size of the object is greater than this value, it will bypass the new generation and allocate directly in the old generation. This parameter is only valid for serial collectors and ParNew collections, but not for ParallelGC collectors.

Guess you like

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