close、dispose、finalize、GC、Idisposable、……你对它们有清楚的描述吗?

发布于 2024-07-29 04:53:18 字数 72 浏览 2 评论 0原文

我对 close、dispose、finalize、GC、Idisposable 完全感到困惑。 哦,你能给我一份清晰的描述吗?

i am completely confused about close, dispose, finalize, GC, Idisposable.
Oh, could you please send me a clear description of them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

老旧海报 2024-08-05 04:53:18

这是一个相当大的话题。 我可以推荐一下 Richter 的CLR via C# 这本书吗? 它详细介绍了您提到的所有问题。

非常简短的翻译:

  • 在一次性类型上,“关闭”通常与“处置”相同。
  • Dispose 用于允许确定性地清理垃圾收集未处理的资源。
  • Finalizer(或 C# 语言规范所称的析构函数)是垃圾收集代码在某个时间点调用的清理方法。 即,与 C++ 的析构函数不同,这不是在明确定义的时间点完成的。
  • GC 是垃圾收集的缩写,指 .NET 对托管堆上对象的自动清理。
  • IDisposable 是一个接口,它声明相关类型实现了上面概述的 Dispose 方法。

更多详情请查阅本书。 这篇相当详尽的博客文章 Joe Duffy 的著作对于理解 IDisposable 和终结器也非常有用。

That is a fairly large topic. May I recommend the book CLR via C# by Richter. It goes into details about all the issues you mention.

A very brief translation:

  • On disposable types Close is often the same as Dispose.
  • Dispose is used to allow deterministic clean up of resources not handled by garbage collection.
  • Finalizer (or destructor as the C# language spec calls it) is a clean-up method called by the garbage collection code at some point in time. I.e. unlike destructors for C++ this is not done at a well defined point in time.
  • GC is short for garbage collection and refers to .NET's automatic clean-up of objects located on the managed heap.
  • IDisposable is an interface, that states that the type in question implements the Dispose method as outlined above.

For more details please consult the book. This rather elaborate blog entry by Joe Duffy is also very useful for understanding IDisposable and finalizers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文