Will ignoring IDisposable cause memory leaks?

前端 未结 7 1309
攒了一身酷
攒了一身酷 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条回答
  •  旧时难觅i
    2021-01-02 02:27

    Failing to call IDisposable on objects which subscribe to events from longer-lived objects will extend the memory-allocation lifetime of the subscriber to be extended to that of the publisher. If there is no upper bound to the number of subscribers that may be attached and abandoned during a publisher's lifetime, this will constitute an unbounded memory leak.

提交回复
热议问题