Many classes require that Dispose be called to ensure correctness. If some C # code uses an iterator with a finally block, for example, the code in this block will not be run if the counter is created with this iterator and will not be deleted. Although there are a few cases where it would be impractical for objects to be cleaned without finalizers, for the most part code that relies on finalizers to work properly or to avoid memory leaks is bad code.
If your code acquires ownership of the IDisposable object, then if no object is closed or your code creates the object by calling the constructor (unlike the factory method), you cannot find out what the real type of the object is, and whether it is possible safe to leave. Microsoft may have initially assumed that it’s safe to abandon any type of object, but this is unrealistic, and the belief that it would be safe to abandon any type of object is futile. If an object subscribes to events, to ensure safe rejection, it is either necessary to add a level of weak indirectness to all events, or a level of (non-weak) access to all other accesses. In many cases, it is better to require the caller to delete the object correctly than to add significant overhead and complexity, allowing you to refuse.
We also note, by the way, that even when objects try to satisfy a failure, it can still be very expensive. Create a Microsoft.VisualBasic.Collection (or whatever it's called there), add a few objects, and create and destroy a million enumerators. No problem - it is very fast. Now create and leave a million enthusiasts. A big holiday of delay, if you do not hit GC every few thousand enumerators. The Collection object is written to resolve a failure, but this does not mean that it does not have significant costs.
source share