104

Go 垃圾回收 | nino's blog

 6 years ago
source link: https://ninokop.github.io/2017/11/09/Go-%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6/?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
通常C++通过指针引用计数来回收对象,但是这不能处理循环引用。为了避免引用计数的缺陷,后来出现了标记清除,分代等垃圾回收算法。Go的垃圾回收官方形容为 非分代 非紧缩 写屏障 并发标记清理。标记清理算法的字面解释,就是将可达的内存块进行标记mark,最后没有标记的不可达内存块将进行清理sweep。 三色标记法判断一个对象是不是垃圾需不需要标记,就看是否能从当前栈或全局数据区 直接或间接的引用到这个

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK