何时循环引用存在.NET垃圾回收器问题 [英] A Question about the .NET garbage collector when cyclic references exist

查看:142
本文介绍了何时循环引用存在.NET垃圾回收器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,.NET垃圾回收器检测到循环引用,但我不知道循环引用是否可能会导致物体停留需要更长的时间。

I'm aware that the .net garbage collector detects cyclic references but I was wondering whether cyclic references may cause objects to stay longer than necessary.

我在我的ASP.NET应用程序中的循环引用(希望的一对性能方面的原因),我可以与脱身?

I have a cyclic reference in my ASP.NET app (an intended one for performance related reasons), can I get away with that?

问候

推荐答案

它并不需要的CLR不再删除比非循环引用循环引用。 CLR使用技术来收集垃圾的组合。快速的版本,虽然是它植根于所有对象(在栈上的对象,或具有较强的GC手柄举行)开始。任何对象,它是从访问这些对象是活的。任何东西都不会被收集。循环引用不会影响该算法比其他CLR的结果,有一定要检查他们,而不是走在圈子

It doesn't take the CLR any longer to remove a cyclic reference than a non-cyclic reference. The CLR uses a combination of techniques to garbage collect. The quick version though is it starts with all rooted objects (objects on the stack, or held with a strong GC handle). Any object that is reachable from these objects is alive. Anything else will be collected. A cyclic reference won't affect the results of this algorithm other than the CLR has to make sure to check for them and not walk in circles

这篇关于何时循环引用存在.NET垃圾回收器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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