O'Reilly logo

ASP.NET Site Performance Secrets by Matt Perdeck

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unmanaged resources

Some commonly used objects are based on unmanaged resources, such as file handles and database connections. These file handles and connections are scarce resources. When these objects lose all references, the garbage collector will eventually remove them and in the process, release the scarce resources they have in use. However, instead of waiting for the garbage collector, you'll want to release the scarce resources the moment they are no longer in use so that another thread can use them.

IDisposable

To allow your code to do this, these objects implement the interface IDisposable. This exposes the method Dispose(), which disposes the object. They also often implement a method Close() with the same functionality as Dispose() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required