- informs GC that object does not need to be added to finalizer queue
- finalizer execution is not deterministic and objects can live for long time in queue – this is optimization technique
- to make sure that object disposes of any unamanaged resources even if
Disposewill be not called we need to implement finalizer
Basically finalizer execution time is not deterministic. We cannot predict when this will be called and till that time – object is existing and still taking memory space. Since we are controlling creation and disposal of those resources we can say to GC: ‘Do not worry about that! It already had been taken care of!’. So this way object will be destroyed sooner, leaving this space to be used by something else possibly.
The Dispose() method must callMSDN
Dispose(true)and should suppress finalization for performance.