What is the significance of the “finalize” method ?
In order to understand the “finalize” method one needs to understand the concept of garbage collection.
The job of freeing up the memory allocated to objects is that of a garbage collector. When the garbage collector determines that an object is no longer referenced it automatically runs a special destructor function called “Finalize”. However we have no way to determine when the garbage collector will call the Finalize method. We can only be sure that it will be called at some time after the last reference to the object is released.
Finalize is a protected method i.e. it can be called from the class or derived classes however it cannot be called from outside of the class. If a class has a Finalize method it should explicitly call the Finalize of its base class as well.
Overrides Protected Sub Finalize ()
‘Cleanup code goes here
BaseClass.Finalize
End Sub
