Disposing Windows SharePoint Services objects


I came accross this article on MSDN about disposable WSS 3.0 objects. I recommend anyone working with the SharePoint object model to give this article a thorough read.

The article outlines the fact that the two main classes in the object model SPSite and SPWeb both use unmanaged code and without proper disposal can seriously harm the performance of your SharePoint site.

Both these classes implement the IDisposable interface and best practice with .Net code generally is if a class exposes a Dispose method then you should always call that Dispose method to clean up any unmanaged resources the object might have used.

Not adhering to this best practice when using the SharePoint object model can hurt the performace of your site quite badly and when you realise how much more memory the unmanaged part of the object consumes compared to the managed part you will soon realise how important cleaning up them unmanaged reasources is.

Anyway the article goes into more depth so get over to MSDN and have a read.

http://msdn2.microsoft.com/en-us/library/aa973248.aspx

kick it on DotNetKicks.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s