当前位置:网站首页>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 Kernel wo system source Commercial Open source multi - user + multi - Customer Service + SMS + email notification
- idea自动导包和自动删包设置
- Cannot activate CONDA virtual environment in vscode
- One step implementation of yolox helmet detection (combined with oak intelligent depth camera)
- Arbre binaire pour résoudre le problème (2)
- Knowledge arrangement about steam Education
- Leetcode- insert and sort the linked list
- Mapping location after kotlin confusion
- [Yu Yue education] autumn 2021 reference materials of Tongji University
猜你喜欢
How to recover deleted data in disk
Three years of experience in Android development interview (I regret that I didn't get n+1, Android bottom development tutorial
Lay the foundation for children's programming to become a basic discipline
万卷共知,一书一页总关情,TVP读书会带你突围阅读迷障!
Learn BeanShell before you dare to say you know JMeter
VMware installation win10 reports an error: operating system not found
社交媒体搜索引擎优化及其重要性
One step implementation of yolox helmet detection (combined with oak intelligent depth camera)
農業生態領域智能機器人的應用
Realize the function of data uploading
随机推荐
[understand one article] FD_ Use of set
Cache consistency solution - how to ensure the consistency between the cache and the data in the database when changing data
Geotrust OV Multi - Domain Domain SSL Certificate rmb2100 per year contains several Domain names?
Application of intelligent robot in agricultural ecology
geotrust ov多域名ssl證書一年兩千一百元包含幾個域名?
GeoTrust ov multi domain SSL certificate is 2100 yuan a year. How many domain names does it contain?
Alibaba cloud polkit pkexec local rights lifting vulnerability
Rhcsa --- work on the fourth day
Rhcsa --- work on the third day
Pytest learning ----- pytest Interface Association framework encapsulation of interface automation testing
農業生態領域智能機器人的應用
Pytorch-Yolov5从0运行Bug解决:
Research on the security of ognl and El expressions and memory horse
Flag bits in assembly language: CF, PF, AF, ZF, SF, TF, if, DF, of
Starting from the classification of database, I understand the map database
What are the rules and trading hours of agricultural futures contracts? How much is the handling fee deposit?
二叉樹解題(二)
[C language] Dynamic Planning --- from entry to standing up
6月书讯 | 9本新书上市,阵容强大,闭眼入!
Leetcode- insert and sort the linked list