问题描述
我读到GC,我意识到没有一个GC的工作,但两路?
I read about GC and I realized there is not one way that the GC works but two?
首先是正常的GC:
- 使用的应用程序根检测的垃圾对象
- 收集的对象释放,在freachable队列
- 所有调用该对象的finalize方法在freachable队列
- 删除下次GC一轮全部结束掉的对象。
- Detect the garbage objects using the application roots
- Gather the objects to free, in the freachable queue
- Call the finalize method of all the object in the freachablequeue
- Erase all the finalized objects in the next GC round.
二是代GC:
- 扫描对象和检测对象以自由和清除它们
- 通过那些存活到第2代(扫描他们少次)
- 传递最存活对象一代3。
- Scan the objects and detect the objects to free and erase them
- Pass the ones that survived to generation 2 (to scan them lesstimes)
- Pass the most survived objects to generation 3.
我完全糊涂了:是这两种不同类型的GC的?或者说是代GC是像第一的升级?抑或是一样的吗?
I'm totally confused:are these two different types of GC? Or is the generational GC is like an upgrade of the first? Or is it the same?
那是什么的.NET工作?
What is the way that the .NET works?
推荐答案
.NET是像你描述的代pretty的多。 东西触发GC通。这关的幸存者被提升到下一代,依此类推直到第2代(从第0级,所以一共有2促销)。
.NET is generational pretty much as you described. "Something" triggers a GC pass. Survivors of this pass are promoted to the next generation and so on until Generation 2 (starting at Gen 0, so a total of 2 promotions).
GC通过高在几代人,因为他们可以更昂贵的少了。
GC passes higher up in the generations are fewer between because they can be more expensive.
本博客(和在网络上许多其他来源)给出了GC的一个很好的概述在.NET中:
This blog (and many other sources on the net) gives a good overview of GC in .NET:
的
的
你所描述什么似乎是两个半部到.NET故事。我相信你对终结和内部队列(freachable)概述大多是准确的(不知道),但这样的生成行为。
What you have described appears to be the two halves to the .NET story. I believe your overview about the finalizer and internal queues (freachable) are mostly accurate (not sure), but so is the generation behaviour.
这太问题也骤降类似海域的脚趾:
This SO question also dips its toe in similar waters:
Garbage收集在净implementaion,对象的行为是未知的,无法理解他们的
这篇关于代垃圾回收VS .NET中的垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!