Skip to main content

Posts

Showing posts from September, 2011

When to implement IDisposable?

In .Net, garbage collector is very good at cleaning up managed resources. Managed resources are object implemented using .Net framework and something that the Garbage collector is aware of. Unmanaged resource is anything that is implemented outside .Net framework and Garbage collector has no information about it. The combination of Destructor and Dispose can be used to release unmanaged resources for e.g open files or database connection. If you are not using any unmanaged resource, there is no need to implement IDisposable. Garbage collector will take care of release the unused objects and freeing up the memory.