当前位置:网站首页>GC tuning principle of JVM (7)
GC tuning principle of JVM (7)
2022-07-20 10:48:00 【uesowys】
1 G1(Garbage-First) The collector
1.1 General overview
1.2 Launch parameters
1.3 Basic concepts
1.3.1 Stack layout
1.3.2 GC cycle
chart 1
Pictured above 1 Shown ,GC The period is abstracted into a circle , There are two stages , The first half cycle stage is defined as the young generation collection stage (Young-only), The second half cycle stage is defined as the space recycling stage (Space Reclamation), The two stages change continuously in a clockwise direction , So that G1 Of GC cycle , The operation mechanism of these two stages is discussed in detail below .
Only the younger generation collection stage (Young-only): At the beginning of the first half circle , Perform ordinary young generation collection ( Similar to the previous collector type minor collection,GC The operation time is short , The smaller blue solid dot in the upper half circle ), Its main task is to continuously increase the survival objects of the younger generation and eventually replicate them into the older generation . When the space occupied by the old generation stack area is greater than the set threshold , Then trigger the concurrent marking process , This process is illustrated from the following aspects :
Concurrency starts (Concurrent Start), This moment indicates the beginning of the concurrent marking process , Then execute the concurrency flag ( The larger blue solid dot in the upper half circle ) Operation and some common younger generation collection operations . The task of concurrent marking operation is to determine all the reachable survival objects in the current generation heap , The next stage of supply follows ( The space recovery stage of the lower half circle ) Use . Because it is parallel operation , Therefore, ordinary young generation collection operations will also be executed concurrently . When re marking operation (Remark, The larger yellow solid dot in the upper half circle ) And clear operation (Cleanup, The larger yellow solid dot in the upper half circle ) When it's done , Then the concurrent marking process ends .
It can be seen from the discussion in the previous chapter ,JVM Use heuristic behavior analysis method to optimize its GC operation , At the beginning of the above concurrency flag ,JVM Will continue to collect and analyze applications and GC Behavior data of , To determine whether subsequent Remark And Cleanup operation , If you don't need to , be JVM Perform a short concurrent mark redo operation , Then proceed clockwise .
Re label (Remark), This is a GC Pause the marking operation under , It forms a complete marking process with the concurrent marking operation mentioned above . Relabel the reference relationship of the main processing object 、 Unload class 、 Reclaim empty areas and empty internal data structures . stay Remark And CleanUp There is a concurrent common young generation GC operation , Its function is for the follow-up CleanUp Operation provides information about data calculation and data analysis , This information includes the space in the elderly generation stack area that will be recycled .
eliminate (CleanUp), This is a GC Clear operation under pause , Recycle the old generation heap space to be cleared provided in the previous steps . meanwhile , This operation also determines whether it is necessary to start the next stage through calculation (Space Reclamation) The operation of , if necessary , Then make some simple preparations for the next stage , If you don't need to , Then restart the execution Young-only Stage .
Space recycling stage (Space Reclamation): The lower half of the circle includes many pink solid dots of the same size , Its size is the same as the real point size of the ordinary young generation collection operation shown in the previous stage , But the colors are different , Its meaning is , This is a hybrid younger generation collection operation , Its hybrid operation includes ordinary younger generation operation 、 The operation of copying the living objects of the old generation heap space to the new old generation heap space in a mobile manner, so as to reclaim the old generation heap space ( Compress and store surviving objects ), After many mixed operations , When G1 Make sure enough free heap space has been freed and reclaimed , Then the stage ends , Then open the next new Young-only Stage .
From the above analysis, we can see , stay Space Reclamation In phase ,JVM Provide abnormal process , If the memory space of the application is insufficient , Then trigger complete GC operation (Full GC), Completely GC It is for the global memory heap GC operation , It takes long enough , The impact on application throughput is very obvious , So try to avoid completely GC Happen . When complete GC Operation cannot solve the problem , be JVM Will throw out OutOfMemoryException Exception information for , explain GC The total pause time has taken up of the total running time of the application 98% above .
( To be continued )
边栏推荐
猜你喜欢
随机生成10(范围1~100)个整数,保存到数组,并倒序打印该数组。以及求平均值、最大值和最大值的下标、并查找里面含有某一数字的个数。
Gocore-v2 framework - quick start
Kubernetes技术与架构(二)
Pytorch:torchvision包-总结
Calculation process of pytorch gradient
若依框架集成JimuReport积木报表
3Dslicer中使用opencv连接相机
Modelsim报错“Instantiation of ‘****‘ failed. The design unit was not found.”
Using OpenCV to connect cameras in 3dslicer
I understand MVC
随机推荐
FPGA仿真时使用任务及随机函数编写激励测试文件
今天学习定位
零碎知识点(一)
Data type conversion
Distributed unique ID
京东快速导航框
3DSlicer扩展模块如何加入外部扩展包?
若依框架集成JimuReport积木报表
Introduction to 3dslicer default extension module program
JSON对象
高度塌陷及解决方案
huawei link agg and port mirroring
文档流定义,盒子模型相关知识
Devops: from the "steam age" to the "high-speed rail age", Sunmi Devops' Transformation Road
boolean到底占几个字节?
FPGA之简易频率计的设计
JVM之GC调优原理(十)
基于IF嵌套与函数调用
Go zero business development Arsenal
FPGA之阻塞赋值与非阻塞赋值的理解