.Net: Garbage Collector and Finalizers

Garbage Collector and Finalizers have an important difference to be marked of:

The responsibility of a garbage collector is to manage and utilize only the memory of the .net application and to call the finalizer (or destructor).

Finalizers(or destructors) are not responsible for memory management. Rather, they are responsible for freeing up resources such as database connections, file handles, open ports and other resources that must be freed when the object in question is garbage collected bcoz the garbage collector doesn't know about them.

Reference: Essential C# 2.0 by Mark Michaelis

Comments