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

When will GC be triggered?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Young GC---- is aimed at the younger generation

When the Eden area is full, Young GC will be triggered

Full GC---- targets the entire heap

1. When Young GC occurs, the virtual opportunity detects whether the average size of each promotion to the old age is larger than the remaining space of the older generation, and if so, the Full GC is performed directly.

two。 If it is less than, but Handle PromotionFailure is set, then Full GC is also executed. Promotion failed is in the process of Minor GC, survivor space can not be put down, objects can only be put into the old era, and the old era can not be put down.

3. Lack of permanent generation space, Full GC will be triggered

4. System.gc () also triggers Full GC

5. Large objects allocated in the heap

The so-called large object refers to the java objects that need a lot of continuous memory space, such as a very long array, which will directly enter the old age, while in the old age, although there is a lot of remaining space, but can not find enough continuous space to be allocated to the current object, this situation will trigger JVM to Full GC. To solve this problem, the CMS garbage collector provides a configurable parameter, the-XX:+UseCMSCompactAtFullCollection switch parameter, which is used to give away an additional free defragmentation process after "enjoying" the Full GC service. The memory defragmentation process cannot be concurrently, and the space debris problem is gone, but the Teton time has to be longer. JVM designers also provide another parameter-XX:CMSFullGCsBeforeCompaction, which is used to set the number of times an uncompressed FullGC is executed, followed by one with compression.

6. CMS GC concurrent mode failure

CMS GC---- is aimed at the older generation

Configure-XX:CMSInitiatingOccupancyFraction=75 and-XX:+UseCMSInitiatingOccupancyOnly, and set CMS to start GC when the memory occupancy reaches 75%.

Configured with-XX:+CMSClassUnloadingEnabled,CMSInitiatingPermOccupancyFraction=80%, that is, the use of Perm Gen reaches a certain rate, with a default of 92%

When-XX:+ExplicitGCInvokesConcurrent is configured and-XX:+DisableExplicitGC is not configured, it shows that System.gc () is called

CMS only collects old gen when it works in concurrent mode. However, once the concurrent mode fails (concurrent mode failure occurs), there is a selective full heap collection, that is, falling back to full GC.

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