What is the finalize block in .net ?
What is the finalize block in .net ?
It will belong to object class,automatically called garbage collection mechanism object go out of scope also it is an slower methods not suitable for instant disposing object,it is an non deterministic function.
Finalize method is used to perform cleanup operations on unmanaged resources held by the current object before the object is destroyed
The Finalize method is used to perform cleanup operations on unmanaged resources held by the current object before the object is destroyed.
Object.Finalize method in .NET is typically used to clean and release unmanaged resources like OS files, window etc. Even though Garbage collector in .NET has the ability to determine the life time of such objects, however, with no knowledge how to clean them. The Finalize method allows an object to clean up such unmanaged resources when the garbage collector wishes to reclaim the memory. However, Finalize method should be avoided until necessary as it affects the performance because reclaiming the memory used by objects with Finalize methods requires at least two garbage collections.
The method is protected and therefore is accessible only through this class or through a derived class.
Bookmarks