Friday 6 July 2012

How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?

Purpose:
  • Even though .Net is a managed framework it does not abscond developers from having to understand how memory management works under the hood. Being able to explain the purpose behind the IDisposable interface and supporting language features to manipulate garbage collection is a mark of a professional developer.

Potential Answer:
The using pattern or keyword is a way to allow us to use an expensive object in a deterministic or predictable manner and ensure garbage collection is done after we are done using the resource. For objects that require such deterministic collections we may opt to implement the IDisposable interface to allow for non GC based collection being invoked..

No comments:

Post a Comment