Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the ways in which the new generation of Java objects have entered the old age?

Shulou Source: shulou.com Published: 2022-06-02 04:18:27 10月02日 Update

Today, I would like to talk to you about the ways in which the new generation of Java objects have entered the old age. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can gain something according to this article.

The big object goes directly into the older generation.

Large objects are Java objects that require a lot of contiguous memory space, such as long strings and arrays. Garbage collection is triggered in advance to get enough contiguous space to accommodate large objects when there is still a lot of space in memory.

The virtual machine provides a-XX:PretenureSizeThreshold parameter that allows objects larger than this setting to be allocated directly in the old days. The purpose of this is to avoid a large amount of memory replication between the Eden area and the two Survivor zones (the new generation uses the replication algorithm to collect memory).

Those who survive for a long time will enter the old generation.

The virtual machine defines an object age counter for each object. If the object is still alive after the first Minor GC created in Eden and can be accommodated by Suivivor, it will be moved to the Survivor space and the object age will be set to 1. Every time you experience Minor GC, your age will increase by 1 year, and when you reach a certain level (default 15 years old, you can set it through the parameter-XXMaxTenuringThreshold), you will be promoted to the older generation.

Dynamic object age determination

In order to better adapt to different program memory conditions, virtual machines do not rigidly require objects to reach the age of MaxTenuringThreshold in order to promote the old age. If the total size of all objects of the same age in the Survivor space is more than half of the Survivor space, objects older than or equal to that age can directly enter the old generation.

After reading the above, do you have any further understanding of the way the new generation of Java objects enters the old age? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Object age space memory age freshman Cenozoic content mode parameter promotion different same two between dynamic can pass garbage size character Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Docker macOS Shulou Technology Shulou Tech Info