Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Memory allocation and recovery method for JVM objects

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "JVM object memory allocation and recycling method". In daily operation, I believe many people have doubts about JVM object memory allocation and recycling method. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "JVM object memory allocation and recycling method". Next, please follow the editor to study!

Objects are assigned first on the Eden

In most cases, objects are allocated first in the Cenozoic Eden region. When the Eden memory area does not have enough space to allocate, the virtual machine will trigger a Minor GC (new generation GC). During Minor GC, the virtual machine moves objects from the Eden area to one of the Survivor areas.

The big object went straight into the old age.

The so-called large object refers to the object that needs a lot of continuous space. The virtual machine provides a XX:PretenureSizeThreshold parameter that allows objects larger than this value to be allocated directly in the old age.

Long-term surviving objects will enter the old age.

Virtual machines use the idea of generational collection to manage memory, so memory collection must be able to identify which objects should be placed in the new generation and those in the old age. In order to do this, the virtual machine defines an object age Age for each object. Each time a new generation of GC is passed, the object still survives. The object's age Age is increased by 1 year. When the current age reaches a certain degree (default is 15), it will be promoted to the old age. The age limit for the object to be promoted to the older generation can be set by-XX:MaxTenuringThreshold.

The difference between Minor GC and Full GC

New generation GC (Minor GC): refers to the garbage collection actions that occur in the new generation. Because most of the objects have the characteristics of dying forever, Minor GC is very frequent and the collection speed is relatively fast.

Old GC (Major GC / Full GC): refers to the GC that occurred in the old years. After the emergence of Major GC, it is often accompanied by Minor GC at least once. Major GC is generally more than 10 times slower than Minor GC.

At this point, the study on the method of memory allocation and recycling of JVM objects is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report