当前位置:网站首页>ZGC message type and trigger time

ZGC message type and trigger time

2022-06-09 06:24:00 lixia0417mul2

gc Message type
Trigger zgc There are two types of messages for , One is synchronous message , One is asynchronous message , For synchronous messages , The thread that triggers the synchronization message waits gc You can't continue running until you're done , such as System.gc The message of is a synchronous message , The application thread needs to wait gc You can't continue running until you're done , When the last synchronization message triggered gc It is still in progress, and then another synchronization message request is received , Will trigger in sequence gc, Asynchronous messages are message types that are triggered by similar fixed trigger intervals , When caused by the last asynchronous message gc While it's still going on , If you receive another request for an asynchronous message , That will ignore new asynchronous messages , That is, asynchronous messages will be de duplicated
Synchronization message trigger timing
System.gc It is a synchronous message sending method triggered actively in the code , This is what developers think jvm At this time, the garbage has reached the point of cleaning up , So it will trigger gc, Because it is a synchronous message type , Only gc After the end ,System.gc Later code can continue to execute
Asynchronous message trigger timing
1. Trigger at regular intervals
ZCollectionInterval Parameter controls the fixed time interval for triggering asynchronous message garbage collection , Give Way gc Triggered at a fixed frequency , For example, the trigger is fixed every morning gc, In this way, it is not easy to wait for peak traffic during the day gc 了
2.jvm The warm-up rule is triggered at startup
jvm Just started , Triggered by historical data gc The rules , Therefore, the trigger rules at startup are designed , Specifically, when jvm Heap memory reached... At startup 10%,20%,30% Will trigger asynchronism gc news , But when the startup process is over , This rule will not be satisfied again
3. Triggered according to the allocation rate
zgc The runtime will collect data from the past gc frequency ,gc Time , Program memory allocation rate , Parameters such as free memory of heap memory , The purpose is to predict when the heap memory space will be exhausted according to the free heap memory and the program memory allocation rate , such gc It can be triggered in advance before the heap memory is about to run out gc operation , Avoid entry oom. By the way , This rule predicts the next gc The trigger time can be predicted using the linear regression model of machine learning .
This gc Triggering rules do not require any parameter control , It exists and is enabled by default
4. Active trigger rules
adopt ZProactive Parameter to control whether the active trigger rule is enabled , Default on , The active trigger rule means that the sending will be triggered when the following conditions are met gc Asynchronous messaging , Conditions 1 From the last time gc Recycle to current time , The heap memory usage of the application has increased by more than 10% The heap memory size of , Conditions 2 Is the time from the last process to the current time , Time has passed 5 minute , When the above two conditions are met, the asynchronous gc Sending of messages
Meta space allocation trigger rule
When sending meta space memory allocation fails , It will be sent first gc Asynchronous message triggers gc Recycling , If it can, it will reclaim enough meta space memory , Then return to success , Otherwise, send a synchronization message to trigger gc Recycling operations , If you can reclaim enough meta space memory , Then return to success , Otherwise, try to expand the Metaspace memory , Then allocate the memory .

原网站

版权声明
本文为[lixia0417mul2]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090623128624.html