Markandsweep algorithm

Mark-and-sweep algorithm

  This algorithm reduces the definition of "an object is not needed anymore" to "an object is unreachable".

  从"an object is not needed anymore" 进化到 "an object is unreachable".

  This algorithm assumes the knowledge of a set of objects called roots  Periodically, the garbage-collector will start from these roots, find all objects that are referenced from these roots, then all objects referenced from these, etc. Starting from the roots, the garbage collector will thus find all reachable objects and collect all non-reachable objects.

  从roots扫描,找出所有可引用点,同时剩下的也就是不可引用点。

 

  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 not needed anymore".

  近几年的GC改进都是基于此算法的改进。

原文地址:https://www.cnblogs.com/tekkaman/p/2578131.html