Will ignoring IDisposable cause memory leaks?

前端 未结 7 1267
攒了一身酷
攒了一身酷 2021-01-02 02:04

In the comments to an answer I wrote we had a discussion about memory leaks and IDisposable where we didn\'t come to any real conclusion.

A class that h

相关标签:
7条回答
  • 2021-01-02 02:53

    It will not cause a memory leak. In fact, Dispose has absolutely nothing to do with memory management.

    It will create a resource-leak. And while the GC will usually clean it up, this could be too infrequent and too late.

    Omitting Dispose (using) can slow down or even crash your App. In the case of file resources or Db connections it can even cause problems in other applications.

    0 讨论(0)
提交回复
热议问题