我们怎么知道对象的引用计数是多少?有时希望计数在释放时等于1,而不是在VB自动释放时为0 [英] How do we know an object's reference count is how much? Sometimes hope count is equal to 1 on the release, rather than to 0 when released automatically by the VB

查看:124
本文介绍了我们怎么知道对象的引用计数是多少?有时希望计数在释放时等于1,而不是在VB自动释放时为0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何知道对象的引用计数是多少?有时希望计数在释放时等于1,而不是在VB自动释放时为0。

How do we know an object's reference count is how much? Sometimes hope count is equal to 1 on the release, rather than to 0 when released automatically by the VB.

推荐答案

你没有。对象不参考计数;引用计数方案具有循环引用问题,其中两个对象相互引用但是无法访问,因此泄漏。

.NET使用标记和扫描方法,该方法不使用引用计数。 br />
请参阅: http://msdn.microsoft.com/en-us/ library / ee787088.aspx [ ^ ] - 查看垃圾收集过程中会发生什么部分。
You don't. Objects are not reference counted; reference counting schemes have the circular reference problem, where two objects refer to each other but are otherwise inaccessible and therefore leak.
.NET uses a "mark and sweep" approach which does not use reference counts.
See here: http://msdn.microsoft.com/en-us/library/ee787088.aspx[^] - look under the "What happens during a garbage collection" section.


这篇关于我们怎么知道对象的引用计数是多少?有时希望计数在释放时等于1,而不是在VB自动释放时为0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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