Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 1

What is the difference between Dispose and Finalize method ?

Finalize() method will be called by the runtime. i.e, Garbage collector will take the
responsiblity to deallocate the memory for the specific object. But the problem is we can
not assume when it will be deallocated. For that, .NET framework supports Dispose(), by
using this when ever you think, the object no longer needed, as soon as possible you have
to specify objname.dispose(). in u r code.
One more question may be raised in this topic, how to destroy the object of com
component in u r .NET application. because CLR does not take the responsiblity to
deallocate the objects for unmanaged code. To do this, System.Runtime.InteropServices
namespace provides one class named Marshal.ReleaseComObject(object name)
By using this we can deallocate the memory for com componet in .NEt application.

You might also like