当前位置:网站首页>Go GC garbage collection notes (three color mark)
Go GC garbage collection notes (three color mark)
2022-07-02 04:50:00 【Chirp cat】
Go GC Garbage collection notes
Go 1.3
Mark removal method
Conduct STW, from main Function starts looking for memory usage ( Root reachability algorithm traverses ).
Mark all reachable memory usage .
After marking , Clear these memory occupation .
end STW, The program continues to run .
Go 1.5 after
Tricolor notation
- From the root (main function ) Start looking for root reachable objects , Mark these reachable objects gray , And put it into the gray object queue .
- Take gray objects from the gray object queue , And mark it black . At the same time, the object it refers to is marked as gray , Put it in the gray object queue .
Repeat the above two steps , Until the gray object queue is empty , All the black objects left at this time are the objects being used , All white objects are garbage objects to be cleaned up .
Tricolor notation + Hybrid write barrier
initialization GC Mission , Including opening the write barrier and auxiliary GC, Collect root objects . This stage needs to be carried out STW(Go 1.8 After this step STW It was cancelled ).
Scan all objects , Including the global pointer and the pointer on the stack ,( First scan ) Stop the process when scanning the corresponding process stack ( Stop time is short ), Execute tricolor marking , Empty the gray object queue , Finish marking . This stage is executed in the background .
Because new objects may be added in the process of three color marking , So we need to write a barrier to record these newly added objects . After three color marking , Rescan global variables 、 Pointer and stack ( Second scan ), Compare the two scanning results , Judge whether there are garbage objects in the newly added objects , Or whether there are rewritten references in the marked white objects for the first time , If there is , Then re mark it as gray , Prevent it from being cleared . This stage requires STW.
Recycle all white objects according to the marking results , This stage is executed in the background .
边栏推荐
- 10 minute quick start UI automation ----- puppeter
- Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知
- Application of intelligent robot in agricultural ecology
- Hcip day 17
- 数学问题(数论)试除法做质数的判断、分解质因数,筛质数
- Several methods of capturing packets under CS framework
- Why can't you remember when reading? Why can't you remember- My technology learning methodology
- [understand one article] FD_ Use of set
- Pytoch yolov5 runs bug solution from 0:
- What methods should service define?
猜你喜欢

LeetCode-对链表进行插入排序

2022-003arts: recursive routine of binary tree

TypeScript函数详解

Why can't you remember when reading? Why can't you remember- My technology learning methodology

正大美欧4的主账户关注什么数据?
![Learn AI safety monitoring project from zero [attach detailed code]](/img/a9/cb93f349229e86cbb05ad196ae9553.jpg)
Learn AI safety monitoring project from zero [attach detailed code]

What methods should service define?

关于Steam 教育的知识整理

Social media search engine optimization and its importance

解析少儿编程中的动手搭建教程
随机推荐
Use of typescript classes
CorelDRAW Graphics Suite2022免费图形设计软件
Cultivate primary and secondary school students' love for educational robots
[improvement class] st table to solve the interval maximum value problem [2]
Keil compilation code of CY7C68013A
万卷共知,一书一页总关情,TVP读书会带你突围阅读迷障!
Federal learning: dividing non IID samples according to Dirichlet distribution
Let正版短信测压开源源码
Markdown编辑语法
Lay the foundation for children's programming to become a basic discipline
【ClickHouse】How to create index for Map Type Column or one key of it?
正大留4的主账户信息汇总
Use of Baidu map
Major domestic quantitative trading platforms
Deep understanding of lambda expressions
Thinkphp內核工單系統源碼商業開源版 多用戶+多客服+短信+郵件通知
My first experience of shadowless cloud computer
LeetCode-对链表进行插入排序
Design and implementation of general interface open platform - (44) log processing of API services
geotrust ov多域名ssl证书一年两千一百元包含几个域名?