in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

David Wise's Sharepoint blog

Proper Disposal of Objects in SharePoint

I just ran across this article on MSDN that is a fantastic read.  If you do any work where you manipulate SharePoint objects via code, especially SPSite and SPWeb then you must read this.  The article is outlines many of the gotcha's lurking in the object model that you may not be aware of.  There is also another article that touches on object disposal as well but lists a few other areas to watch for.

If you are seeing performance, memory and stability issues in a SharePoint server that is running custom code then that code should be probably be reviewed while the above articles are fresh in mind.

Published Dec 13 2007, 05:41 PM by DavidWise
Filed under:

Comments

 

Chris said:

Good gravy, they're telling me that accessing an array item via an index (e.g. AllWebs) creates an object that I'm responsible for disposing of? I thought that crazy stuff like that went out with C++.

Thanks for the article -- at least it's all in one place. Now I have to rummage through all my code and find all those things I'm doing wrong.

December 14, 2007 6:52 AM
 

DavidWise said:

Yep.  That's why I posted it.  I consider myself a pretty decent programmer and one who is rather careful about releasing resources.  Many of these caught me by surprise, despite knowing what to watch out for.

December 19, 2007 3:26 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

About DavidWise

I have been writing software for over 16 years and web applications for 11 years. I have been also been elbow deep in SharePoint 2007 since Beta 2 and loving it! Currently, I work for Bennett Adelson Consulting (a Microsoft Gold Partner) based in Cleveland, Ohio.

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts