JVM学习笔记-跟踪收集器(Tracing Collectors)

阅读更多

 

Tracing Collectors

Tracing garbage collectors trace out the graph of object references starting with the root nodes. Objects that are encountered during the trace are marked in some way. Marking is generally done by either setting flags in the objects themselves or by setting flags in a separate bitmap. After the trace is complete, unmarked objects are known to be unreachable and can be garbage collected.

跟踪收集器追踪从根节点开始的对象引用图,在追踪过程中对活动对象打上标记。总的来说要么在对象本身设置标记,要么用一个独立的位图来设置标记,当追踪结束时,未被标记的对象就是无法触及的,从而可以被收集。

 

The basic tracing algorithm is called "mark and sweep." This name refers to the two phases of the garbage collection process. In the mark phase, the garbage collector traverses the tree of references and marks each object it encounters. In the sweep phase, unmarked objects are freed, and the resulting memory is made available to the executing program. In the Java Virtual Machine, the sweep phase must include finalization of objects.

基本的追踪算法被称作“标记并清除”。这个名字指出垃圾收集的两个阶段。标记阶段,垃圾收集器遍历引用树,为遍历到对象增加标记,清除阶段,把没有被标记的对象清除,释放其占用的内存空间,在JVM中清除对象必须包含对象的终结。

 

你可能感兴趣的:(JVM学习笔记-跟踪收集器(Tracing Collectors))