代垃圾回收VS .NET中的垃圾收集 [英] Generational Garbage collection Vs Garbage collection in .NET

查看:164
本文介绍了代垃圾回收VS .NET中的垃圾收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到GC,我意识到没有一个GC的工作,但两路?

I read about GC and I realized there is not one way that the GC works but two?

首先是正常的GC:

  1. 使用的应用程序根检测的垃圾对象
  2. 收集的对象释放,在freachable队列
  3. 所有调用该对象的finalize方法在freachable 队列
  4. 删除下次GC一轮全部结束掉的对象。
  1. Detect the garbage objects using the application roots
  2. Gather the objects to free, in the freachable queue
  3. Call the finalize method of all the object in the freachable queue
  4. Erase all the finalized objects in the next GC round.

二是代GC:

  1. 扫描对象和检测对象以自由和清除它们
  2. 通过那些存活到第2代(扫描他们少 次)
  3. 传递最存活对象一代3。
  1. Scan the objects and detect the objects to free and erase them
  2. Pass the ones that survived to generation 2 (to scan them less times)
  3. 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:

http://dotnetfacts.blogspot.co.uk/2008/05/how-garbage-collector-works-part-1.html

http://dotnetfacts.blogspot.co.uk/2008/05/how-garbage-collector-works-part-2.html

你所描述什么似乎是两个半部到.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:

<一个href="http://stackoverflow.com/questions/8560611/garbage-collection-in-net-implementaion-objects-behavior-is-unknown-unable-to">Garbage收集在净implementaion,对象的行为是未知的,无法理解他们的

这篇关于代垃圾回收VS .NET中的垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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