在进行垃圾回收时,我遇到了引用计数
和标记与清除
GC 算法。
网络上的一些研究表明引用计数已成为过去,当今大多数浏览器都采用了标记和清除。根据文章here
Since 2012, JavaScript Engine’s have adapted this algorithm over Reference-counting garbage collection.
虽然我没有找到任何相同的标准文档,但我很想知道以下内容:
- 除了循环依赖之外,还有其他原因让我们放弃引用计数并采用标记和清除吗?
- 所有现代浏览器(Chrome | Firefox | Safari | Edge | IE)都使用“标记和清除”吗?
最佳答案
引用MDN
As of 2012, all modern browsers ship a mark-and-sweep garbage-collector. All improvements made in the field of JavaScript garbage collection (generational/incremental/concurrent/parallel garbage collection) over the last few years are implementation improvements of this algorithm, but not improvements over the garbage collection algorithm itself nor its reduction of the definition of when "an object is no longer needed".
关于javascript - 哪些现代浏览器使用标记和清除算法进行垃圾收集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56218239/