Announcing SPDisposeCheck v14.0.4762.1000 Update for SharePoint Development


Download location:

Update Summary:

I’m happy to announce SPDisposeCheck v14.0.4762.1000 was updated and released today 12/13/2010. 

SPDisposeCheck is a tool that helps developers and administrators check custom SharePoint solutions that use the SharePoint Object Model helping measure against known Microsoft dispose best practices. This tool may not show all memory leaks in your code and may produce false positives which need further review by subject matter experts.

The SPDisposeCheck updated tool remains a standalone command line utility and we’ve added a Visual Studio 2008/2010 IDE Add-In which calls out to the SPDisposeCheck.  This Add-In was originally presented at the SPC 2009 and is now available publically.  In addition this version has been tested with both WSS 3.0 + MOSS 2007 and SharePoint 2010 (Foundation and Server) environments.

Finally, we have added several checks on when “NOT” to Dispose objects instantiated by SharePoint internally.  These newly reported “DO NO DISPOSE” (DND) rules were unreported by SPDisposeCheck v1.3.* .  We would encourage you to run the updated SPDisposeCheck tool on all customized SharePoint projects to help identify areas in code which may lead to memory pressure and server stability issues.  As a best practice you should consider adding this tool to your SharePoint software development life cycle build process and review its output with a subject matter expert on a regular interval.

I plan on posting a follow up on some code examples of when not to dispose object following this initial announcement.

Reference list of Do Not Dispose Rules checked:

  • SPDisposeCheckID_600 = 600, //DO NOT DISPOSE: SPListEventProperties.Web
  • SPDisposeCheckID_605 = 605, //DO NOT DISPOSE: SPWebEventProperties.Web
  • SPDisposeCheckID_610 = 610, //DO NOT DISPOSE: SPItemEventProperties.Web
  • SPDisposeCheckID_615 = 615, //DO NOT DISPOSE: SPItemEventProperties.ListItem.Web 
  • SPDisposeCheckID_620 = 620, //DO NOT DISPOSE: SPItemEventProperties.Web.Site
  • SPDisposeCheckID_625 = 625, //DO NOT DISPOSE: SPItemEventProperties.ListItem.Web.Site
  • SPDisposeCheckID_630 = 630, //DO NOT DISPOSE: SPFeatureReceiverProperties.Feature.Parent               
  • SPDisposeCheckID_635 = 635, //DO NOT DISPOSE: SPList.ParentWeb & SPListEventProperties.List.Web
  • SPDisposeCheckID_640 = 640, //DO NOT DISPOSE: SPWeb.ParentWeb
  • SPDisposeCheckID_645 = 645, //DO NOT DISPOSE: SPContext.Site & SPContext.Current.Site
  • SPDisposeCheckID_650 = 650, //DO NOT DISPOSE: SPContext.Web & SPContext.Current.Web
  • SPDisposeCheckID_655 = 655, //DO NOT DISPOSE: SPSite.RootWeb (Covers -v1 SPSite.LockIssue, SPSite.Owner, SPSite.SecondaryContact checks)
  • SPDisposeCheckID_660 = 660, //DO NOT DISPOSE: SPControl.GetContextWeb(..)
  • SPDisposeCheckID_665 = 665, //DO NOT DISPOSE: SPControl.GetContextSite(..)
  • SPDisposeCheckID_670 = 670, //DO NOT DISPOSE: Microsoft.SharePoint.Administration.SPSiteAdministration.OpenWeb() + 2010
  • SPDisposeCheckID_700 = 700, // Microsoft.SharePoint.SPItemEventProperties.OpenWeb() on Sharepoint 2010

Special thanks to the SPDisposeCheck core development team: Sean Thompson, Greg Varveris, Paul Andrew, and Stefan Goßner !