Will ignoring IDisposable cause memory leaks?

前端 未结 7 1303
攒了一身酷
攒了一身酷 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:34

    To my knowledge the GC will not call Dispose. You have to call it yourself explicitly or use using. So the answer is: Yes, if the class handles unmanaged resources, which are released in Dispose, your class will leak, if you don't call Dispose.

提交回复
热议问题