Could someone explain what might happen if you don\'t Dispose
some IDisposable
entity (by using
or direct Dispose
cal
The most likely effects will be resource locking (e.g. you open a file handle and don't close it - eventually the finalizer will take care of it) or exhaustion (e.g. you do drawing operations and don't dispose of the objects).
This can be a problem, especially with the latter issue, if the memory pressure isn't sufficient to cause a GC (which will kick off the finalization process) in time to use more of the resources. This leads to helpful errors as "a generic error occurred in GDI+."
Poorly written objects may leak memory if they have only a Dispose method and no finalizer, but this is a rarity. Another possibility is that the Dispose method unsubscribes from static events. This could also be a significant problem and will "leak" memory.