Skip to main content
link formatting
Source Link
svick
  • 246.6k
  • 54
  • 407
  • 536

Regarding the Microsoft built classes that inherit IDisposable, do I explicitly have to call Dispose to prevent memory leaks?

I understand that it is best practice to call Dispose (or better yet use a using block), however when programming, typically I don't always immediately realise that a class inherits from IDisposable.

I also understand that Microsoft implementation of IDisposable is a bit borked, which is why they created the article http://msdn.microsoft.com/en-us/library/ms244737%28v=vs.80%29.aspxthe article explaining the correct usage of IDisposable explaining the correct usage of IDisposable.

Long story short, in which instances is it okay to forget to call Dispose?

Regarding the Microsoft built classes that inherit IDisposable, do I explicitly have to call Dispose to prevent memory leaks?

I understand that it is best practice to call Dispose (or better yet use a using block), however when programming, typically I don't always immediately realise that a class inherits from IDisposable.

I also understand that Microsoft implementation of IDisposable is a bit borked, which is why they created the article http://msdn.microsoft.com/en-us/library/ms244737%28v=vs.80%29.aspx explaining the correct usage of IDisposable.

Long story short, in which instances is it okay to forget to call Dispose?

Regarding the Microsoft built classes that inherit IDisposable, do I explicitly have to call Dispose to prevent memory leaks?

I understand that it is best practice to call Dispose (or better yet use a using block), however when programming, typically I don't always immediately realise that a class inherits from IDisposable.

I also understand that Microsoft implementation of IDisposable is a bit borked, which is why they created the article explaining the correct usage of IDisposable.

Long story short, in which instances is it okay to forget to call Dispose?

Source Link
Matthew
  • 26k
  • 9
  • 86
  • 118

For Microsoft built classes that inherit IDisposable, do I explicitly have to call Dispose?

Regarding the Microsoft built classes that inherit IDisposable, do I explicitly have to call Dispose to prevent memory leaks?

I understand that it is best practice to call Dispose (or better yet use a using block), however when programming, typically I don't always immediately realise that a class inherits from IDisposable.

I also understand that Microsoft implementation of IDisposable is a bit borked, which is why they created the article http://msdn.microsoft.com/en-us/library/ms244737%28v=vs.80%29.aspx explaining the correct usage of IDisposable.

Long story short, in which instances is it okay to forget to call Dispose?