世代垃圾收集是如何工作的? [英] How Generational Garbage Collection works?

查看:97
本文介绍了世代垃圾收集是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代GC如何工作?

代GC是什么?



谢谢

解决方案

维基百科的解释


分代GC(也称为
临时GC)将对象分为
代,在大多数周期中,
将只有
代的子集中的对象放入初始白色
(被谴责)集合中。此外,
运行时系统在引用跨越世代
观察创建并覆盖
的引用时保持对
的了解。当垃圾
收集器运行时,它可能能够使用
这个知识来证明初始白色集合中的一些
对象是
不可访问而无需遍历
整个参考树。如果
世代假设成立,则这
会导致更快的收集
周期,同时还会收回大多数
不可到达的对象。


基本上,这是一种启发式的方法。 Garbage集合将新创建的对象放入内存区域(称为 white set )中,当该集合已满时,仍然引用的对象将移动到另一个区域,并且清除并填充白色集合用新鲜的新物体。白色集合是这样的假设:在那里找到的物体通常是不可达的。

有关JVM微调垃圾收集


How Generational GC works ?
Totally what is Generational GC ?

thanks

解决方案

Wikipedia's explanation.

A generational GC (also known as ephemeral GC) divides objects into generations and, on most cycles, will place only the objects of a subset of generations into the initial white (condemned) set. Furthermore, the runtime system maintains knowledge of when references cross generations by observing the creation and overwriting of references. When the garbage collector runs, it may be able to use this knowledge to prove that some objects in the initial white set are unreachable without having to traverse the entire reference tree. If the generational hypothesis holds, this results in much faster collection cycles while still reclaiming most unreachable objects.

Basically, it's a heuristic approach. The Garbage collection puts newly created objects in a memory region (called white set), when this set is full, those objects that are still referenced are moved to another region, and the white set is cleared and populated with fresh new objects. The white set is the hypothesis that the objects found there are generally unreachable.

For further reading on JVM Fine-Tuning of Garbage Collection.

这篇关于世代垃圾收集是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆