Time to ignore IDisposable?
Posted
by Mystagogue
on Stack Overflow
See other posts from Stack Overflow
or by Mystagogue
Published on 2010-04-27T02:52:24Z
Indexed on
2010/04/27
2:53 UTC
Read the original article
Hit count: 462
Certainly we should call Dipose() on IDisposable objects as soon as we don't need them (which is often merely the scope of a "using" statement). If we don't take that precaution then bad things, from subtle to show-stopping, might happen.
But what about "the last moment" before process termination? If your IDisposables have not been explicitly disposed by that point in time, isn't it true that it no longer matters? I ask because unmanaged resources, beneath the CLR, are represented by kernel objects - and the win32 process termination will free all unmanaged resources / kernel objects anyway. Said differently, no resources will remain "leaked" after the process terminates (regardless if Dispose() was called on lingering IDisposables).
Can anyone think of a case where process termination would still leave a leaked resource, simply because Dispose() was not explicitly called on one or more IDisposables?
Please do not misunderstand this question: I am not trying to justify ignoring IDisposables. The question is just technical-theoretical.
© Stack Overflow or respective owner