当前位置:网站首页>Concurrent reachability analysis (three color marking method)
Concurrent reachability analysis (three color marking method)
2022-04-23 00:08:00 【A mouse crossing the street】
The current mainstream programming language garbage collector basically depends on the reachability analysis algorithm to determine the object Is it alive , In theory, reachability analysis algorithm requires that the whole process is based on a snapshot that can guarantee consistency , This means that the running of the user thread must be frozen all the time .
To reduce the impact of freezing user threads , Increase of efficiency , Adopt the method of concurrent marking
The role of concurrency markers
according to Reachability analysis algorithm Core concept of , Using a series of root objects (GC Roots ) As starting point , Search a reference chain according to the reference relationship between objects , Determine the survival of an object by traversing the reference chain .
In the process , The time of root object enumeration is very short and relatively fixed , However , Traverse all reference chains ( Object graph ) The time required is proportional to the number of objects . therefore , The more objects , The more complex the reference relationship between objects , It takes more time to traverse all reference chains to Mark All objects .
The function of concurrency tag is to enable garbage collection thread and user thread to work at the same time , Concurrent execution .
The three color marking method is used to explain
Tricolor notation
-
white : Indicates that the object has not been accessed by the garbage collector . Obviously at the beginning of accessibility analysis , All the objects are Off-white , If at the end of the analysis , Still a white object , That is to say, it's impossible
-
black : Indicates that the object has been accessed by the garbage collector , And all references to this object have been scanned . Black object generation The table has been scanned , It's safe to live , If there are other object references pointing to black objects , No need to scan again . Black is right It seems impossible to directly ( Without going through the gray object ) Point to a white object .
-
gray : Indicates that the object has been accessed by the garbage collector , But at least one reference on this object has not been scanned , That is, you can continue scanning


If and only if the following two conditions are met at the same time , Will produce “ The object disappears ” The question of topic , That is, objects that should have been black are mistakenly marked as white :
-
Insert one or more new references from black object to white object
-
All direct or indirect references from the gray object to the white object are deleted
Solution
Incremental updating The first condition to destroy , When a black object inserts a new reference relationship to a white object , Just put this new Record the inserted reference , After the concurrent scan , Then take the black objects in these recorded reference relationships as the root , Re sweep Trace once . This can be reduced to , Black objects once a new reference to a white object is inserted , It goes back to the gray object 了 .
Original snapshot The second condition is to be destroyed , When a gray object is to delete a reference to a white object , Just delete this In addition to the references recorded , After the concurrent scan , Then take the gray objects in these recorded reference relationships as the root , Rescan once . It can also be reduced to , Whether the reference relationship is deleted or not , Will be based on the snapshot of the object graph at the moment when the scanning just started To search .
版权声明
本文为[A mouse crossing the street]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204222212043912.html
边栏推荐
- Ansible job 1
- FCOS中相较传统anchor-based方法中独特的地方
- 归纳AI数据增强的方法
- A convnet for the 2020s summary
- 根据宽度计算文字大小
- YASKAWA motor servo software sigmawin + cannot be connected to the servo driver
- Niuke bm41 Right view of output binary tree
- BGP basic configuration
- For the pictures in the specified directory, take the picture name (excluding the extension of the picture), separate the file path from the picture name, and separate the file name from the picture e
- 【leetcode】27. Removing Elements
猜你喜欢

Skills of saving images with different depths in opencv

力扣习题集2--两数相加

Swin Transformer网络架构、相应改进模块的理解
![[necessary knowledge] three dimensional imaging principle of line laser scanning](/img/d9/f59809391f10062448f6f9256ea3c2.png)
[necessary knowledge] three dimensional imaging principle of line laser scanning

【ACM】51. Queen n

什么是目标关键词?

API interface knowledge summary

OpenCV中保存不同深度图像的技巧

Teach you two minutes to make a beautiful and easy-to-use 404 page

Day81 (dynamic programming, cross tree traversal)
随机推荐
Is the securities account of goucai school reliable? Is it safe to open an account now? Which securities firm is better?
Detailed explanation of MySQL index
WMS warehouse management system solution
L1-080 multiplication formula sequence (20 points)
对指定目录下的图片,取图片名(不包含图片的扩展名)、将文件路径和图片名分开、将文件名和图片扩展名分开
Go language - use CO process to efficiently calculate the accumulation of each number in 0-2000
Array sorting - basic data type sorting
Ansible Yum warehouse
什么是目标关键词?
YASKAWA motor servo software sigmawin + cannot be connected to the servo driver
node+mongoose分页效果
人为什么看不到事实?
L1-071 previous life files (20 points)
算法---链表求和(Kotlin)
教你两分钟做出一个精美好用的404页面
Mysql中的七种常用查询连接详解
Programming 2022-02 KTV
2022年了,微信商城小程序还值得做吗?
English pronunciation and notes commonly used in OC
【ACM】90. Subset II (the de duplication problem of the same tree layer first needs to sort the array (use sort))