当前位置:网站首页>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 .
边栏推荐
- Websites that it people often visit
- 【毕业季·进击的技术er】年少有梦,何惧彷徨
- Mapping location after kotlin confusion
- Pytorch-Yolov5从0运行Bug解决:
- [Yu Yue education] autumn 2021 reference materials of Tongji University
- 缓存一致性解决方案——改数据时如何保证缓存和数据库中数据的一致性
- MySQL table insert Chinese change? Solution to the problem of No
- What data does the main account of Zhengda Meiou 4 pay attention to?
- Change deepin to Alibaba image source
- Vmware安装win10报错:operating system not found
猜你喜欢
Idea automatic package import and automatic package deletion settings
Leetcode merge sort linked list
unable to execute xxx. SH: operation not permitted
Websites that it people often visit
Starting from the classification of database, I understand the map database
洛谷入门3【循环结构】题单题解
Application of intelligent robot in agricultural ecology
Vmware安装win10报错:operating system not found
万卷共知,一书一页总关情,TVP读书会带你突围阅读迷障!
数学知识——快速幂的理解及例题
随机推荐
Learn AI safety monitoring project from zero [attach detailed code]
关于Steam 教育的知识整理
Use of typescript classes
解析少儿编程中的动手搭建教程
Pytorch-Yolov5从0运行Bug解决:
二叉樹解題(二)
My first experience of shadowless cloud computer
缓存一致性解决方案——改数据时如何保证缓存和数据库中数据的一致性
UNET deployment based on deepstream
Read "the way to clean code" - function names should express their behavior
Practical problem solving ability of steam Education
[improvement class] st table to solve the interval maximum value problem [2]
AcrelEMS高速公路微电网能效管理平台与智能照明解决方案智慧点亮隧道
Thinkphp Kernel wo system source Commercial Open source multi - user + multi - Customer Service + SMS + email notification
VMware installation win10 reports an error: operating system not found
10 minute quick start UI automation ----- puppeter
Vmware安装win10报错:operating system not found
面试会问的 Promise.all()
Beginner crawler - biqu Pavilion crawler
Unity particle Foundation