当前位置:网站首页>zgc的垃圾收集的主要阶段
zgc的垃圾收集的主要阶段
2022-06-12 21:16:00 【lixia0417mul2】
zgc目前是整个堆收集的,没有分代,因此也省却了Rset等跨代记录引用的内存消耗,zgc的整个gc过程主要分为以下阶段:
1.初始标识 (stw): 标识堆中的根对象,根对象主要包括线程栈,全局变量等
2.并发标识:从第一阶段的根出发,并发标识从根对象可达的其他对象,与应用程序并发运行,标识的算法使用的是三色法标记对象,三色法标识对象的原理参见之前的文章
3.重新标识(stw): 该阶段主要是重新标识由于并行阶段的线程并发运行带来的对象漏标识等问题.
4.非强根引用处理: 该阶段处理Finalizer引用,虚引用,弱引用以及幽灵引用等对象
5.重置转移集+回收无效页面:由于上一轮的zgc中,有些对象已经转移到了新的页面,但是对象中实际引用的地址还是旧的地址(因为这些上一轮的对象迁移后,这些对象一直没有被访问到,也就一直没有触发读屏障修改成新地址【不过这种对象数量应该不多】),而在前面的标识阶段后,这些对象实际的引用地址已经修改成到了新地址中,这样就可以安全重置转移表了(因为此时所有的对象引用的值都是新的地址值),重置完转移表后,由于转移表是在旧页面上的,此时也可以顺带回收旧页面了
6.选择待回收的页面(步骤1) :该阶段会回收那些页面中都是垃圾对象的页面,注意这个阶段在zgc中是并发执行的,对应到g1的初始cleanup阶段,不过g1的初始cleanup阶段是stw的,做的事情也比这个zgc的这个阶段要多,比如g1的初始cleanup阶段+并发清理还要根据页面的垃圾大小数量排序页面,为后续的mixed gc制定好计划
7.选择待回收的页面(步骤2):这个阶段会按照每个页面中垃圾大小的占比排序,并选择那些垃圾占比大于阈值(可配置ZFramentLimit)的页面进入垃圾回收候选集中
8.初始转移 stw:这个阶段会转移root对象到新的页面地址中,对应于G1中evacuation阶段的一部分,不过与g1 evacuation整个阶段都是stw的不同,zgc中只有初始转移root阶段是stw的
9.并发转移:zgc转移剩下的非root对象是和应用程序并发执行的,这个阶段对应的是G1中的Evacuation pause阶段(ygc或者mixed gc的转移阶段),注意g1中的Evacuation 阶段是stw的
边栏推荐
- Integrated monitoring solution for power environment of small and medium-sized computer rooms
- Solve one-dimensional array prefix sum
- Social metauniverse: start from redefining yourself
- Allegro Xile technology, a developer of distributed cloud services, received millions of dollars of angel round financing and was independently invested by Yaotu capital
- [tutorial] detailed explanation of the page rules parameter settings of cloudflare CDN
- New product release Junda intelligent integrated environmental monitoring terminal
- 求解一维数组前缀和
- #141 Linked List Cycle
- ASCII code comparison table
- 对闭包的理解
猜你喜欢

Leetcode: 210. Programme II

lintcode:127 · 拓扑排序

#141 Linked List Cycle

String Basics

Composer version degradation

Library cache lock brought by add trandata

Before job hopping, Jin San made up the interview questions. Jin San successfully landed at Tencent and got a 30K test offer

leetcode:210. Schedule II

Access control system based on RFID

Image processing 12- image linear blending
随机推荐
Image processing 12- image linear blending
Is it safe to open an account in flush? How to open an account online to buy stocks
Insert sort
Junda technology is applicable to "kestar" intelligent precision air conditioning network monitoring
测试基础之:单元测试
#981 Time Based Key-Value Store
Inrelease: the following signature cannot be verified because there is no public key: no_ PUBKEY EB3E94ADBE1229CF
leetcode:207. Class Schedule Card
Market trend report, technical innovation and market forecast of hydraulic chain hoist in China
Design and practice of Hudi bucket index in byte skipping
冒泡排序
大小端转换
lintcode:127 · 拓扑排序
Product Manager: "click here to jump to any page I want to jump" -- decoupling efficiency improving artifact "unified hop routing"
居家办公期间如何提升沟通效率|社区征文
Data visualization - Calendar chart
Understanding of closures
Transaction code qs28 of SAP QM preliminary level
Summary of machine learning materials
Simplest ALV template