在 C# 中使用弱引用的 GC 成本?
第二个担忧是 使用弱的运行时开销 参考。明显的成本是 那些创建弱引用和 打电话给他们。一个不太明显的 成本是大量的额外工作 每次GC时都需要完成 运行。
那么弱引用的 GC 成本到底是多少呢?它需要做哪些额外的工作,这有多大?我可以做出一些有根据的猜测,但我对实际的机制感兴趣。
In another question, Stephen C says:
A second concern is that there are
runtime overheads with using weak
references. The obvious costs are
those of creating weak references and
calling get on them. A less obvious
cost is that significant extra work
needs to be done each time the GC
runs.
So what exactly is the cost to the GC of a weak ref? What extra work does it need to do, and how big of a deal is it? I can make some educated guesses, but am interested in the actual mechanics.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请查看 Jeffrey Richter 关于.NET 中的内存管理的文章,它必须清除稍微把事情搞起来。
Please check Jeffrey Richter's article about Memory Management in .NET it must clear up things a little.