I have an idea about Dispose and Finalize method in .Net as laid out below. Is this correct?
Dispose : Implement IDisposable interface and remove unused/unmanaged code in the Dispose()
method. The developer needs to call it manually if they want immediate removal or GC will dispose the resources when it is invoked.
Finalize : When GC invoked it will free the unused managed code and if IDisposable is implemented then it will call the Dispose()
method to free up the unmanaged resources (normally).
Essentially, when we dispose the resources using the Dispose()
method, will memory will be freed immediately and compacted (like the GC does)?