当前位置:网站首页>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 .
边栏推荐
- Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知
- Why can't you remember when reading? Why can't you remember- My technology learning methodology
- Common errors of dmrman offline backup
- Rhcsa --- work on the fourth day
- Three years of experience in Android development interview (I regret that I didn't get n+1, Android bottom development tutorial
- Pytorch-Yolov5从0运行Bug解决:
- Analyze the space occupied by the table according to segments, clusters and pages
- Websites that it people often visit
- C language practice - number guessing game
- VMware installation win10 reports an error: operating system not found
猜你喜欢

Vmware安装win10报错:operating system not found

Analyze the space occupied by the table according to segments, clusters and pages

How to modify data file path in DM database

解析少儿编程中的动手搭建教程

Acelems Expressway microgrid energy efficiency management platform and intelligent lighting solution intelligent lighting tunnel

Embedded-c language-8-character pointer array / large program implementation

Interview question: do you know the difference between deep copy and shallow copy? What is a reference copy?
![[understand one article] FD_ Use of set](/img/57/276f5ef438adee2cba31dceeabb95c.jpg)
[understand one article] FD_ Use of set

Websites that it people often visit

Record the bug of unity 2020.3.31f1 once
随机推荐
VMware installation win10 reports an error: operating system not found
数学问题(数论)试除法做质数的判断、分解质因数,筛质数
Deeply understand the concepts of synchronization and asynchrony, blocking and non blocking, parallel and serial
How to write a client-side technical solution
Idea autoguide package and autodelete package Settings
One step implementation of yolox helmet detection (combined with oak intelligent depth camera)
Steam教育的实际问题解决能力
Summary of common string processing functions in C language
Binary tree problem solving (1)
06 decorator mode
cs架构下抓包的几种方法
unable to execute xxx. SH: operation not permitted
Design and implementation of general interface open platform - (44) log processing of API services
Typescript function details
Mouse events in JS
Unity particle Foundation
DJB Hash
Cultivate primary and secondary school students' love for educational robots
Several methods of capturing packets under CS framework
Cache consistency solution - how to ensure the consistency between the cache and the data in the database when changing data