循环引用的含义。 [英] Implications of circular references.
问题描述
我在同一个项目中的2个类之间有一个循环引用(即
每个类指的是另一个)。该应用程序运行良好,我没有看到
问题,这让我感到惊讶。
是否有任何我没有看到的问题(性能明智或垃圾
收集明智)带循环引用?
谢谢。
我在.NET中知道的唯一循环引用问题是
程序集。 .NET不允许不同程序集中的类
相互引用。
除此之外,没问题。
在消息< ub ************* @ TK2MSFTNGP15.phx.gbl>中,Frank Rizzo
< ;无** @ none.com>写道我在同一个项目中的两个类之间有一个循环引用(即每个类引用另一个类)。该应用程序运行正常,我没有看到任何
问题,这让我感到惊讶。
是否有任何我没有看到的问题(性能明智或垃圾收集明智)使用循环引用?
绕过循环引用问题是.NET使用的垃圾收集算法的优点之一
计算
计划。如果这两个对象都没有可用,那么它们都可以用来获得
GC''d。
-
史蒂夫Walker
Bruce Wood写道:我在.NET中知道的唯一循环引用问题是
程序集。 .NET不允许不同程序集中的类相互引用。
除此之外,没问题。
我知道你不能在
集会之间进行循环引用。我想知道的是,如果单个程序集中的
对象之间存在循环引用,我是否会(可能需要很难解决)问题。
I have a circular reference between 2 classes in the same project (i.e.
each class refers to the other). The app runs fine and I am seeing no
issues, which kind of surprised me.
Are there any issues that I am not seeing (performance wise or garbage
collection wise) with circular references?
Thanks.
The only circular reference issues I know of in .NET are between
assemblies. .NET doesn''t allow classes in different assemblies to
mutually reference each other.
Other than that, no problem.
In message <ub*************@TK2MSFTNGP15.phx.gbl>, Frank Rizzo
<no**@none.com> writesI have a circular reference between 2 classes in the same project (i.e.
each class refers to the other). The app runs fine and I am seeing no
issues, which kind of surprised me.
Are there any issues that I am not seeing (performance wise or garbage
collection wise) with circular references?
Getting round the circular references problem is one of the benefits of
the garbage collection algorithm .NET uses over a reference counting
scheme. If neither object is reachable, they''re both available to be
GC''d.
--
Steve Walker
Bruce Wood wrote:The only circular reference issues I know of in .NET are between
assemblies. .NET doesn''t allow classes in different assemblies to
mutually reference each other.
Other than that, no problem.
I know about the fact that you can''t do circular refs between
assemblies. What I am wondering is whether I''ll have (possibly
difficult to troubleshoot) issues if there are circular refs between
objects in a single assembly.
这篇关于循环引用的含义。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!