Making use of the SPDisposeCheck utility

Most seasoned SharePoint developers have found out one way or another that you have to be mindful of properly disposing your SharePoint objects. Unfortunately, the rules, guidelines and general practices are often confusing and un-intuitive. Because of this it is common to find SPSite, and SPWeb objects that are not properly disposed. To help combat this issue Microsoft has released a tool called the SPDisposeCheck utility that will analyze your assemblies and report on any improperly disposed Shared Point objects.

The utility can be downloaded here:

http://code.msdn.microsoft.com/SPDisposeCheck

To integrate the utility into your development environment, in Visual Studio go to the “Tools” menu and select the “External Tools” menu item. Select “Add” and configure the tools options as follows:

The command argument should point to the SPDisposeCheck executable. Pass the project BIN directory as an argument, and set the initial directory to your solution directory. Select the “Use Output window” checkbox so that the results from the tool display in the Visual Studio output window.

To use the tool, select a project in your solution, and then select the “SPDispose Checker” utility from your tools menu. The results from the tool will display in the output window. If you have any improperly disposed objects, the results in your output window will direct you to where the problems are located in the assembly.

More information about the proper disposal of SharePoint objects the following blog has a great deal of information:

http://blogs.msdn.com/b/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx

avatar

About Everett Comstock

Everett is a Senior Consultant with TCSC. Specializing in SharePoint development he has been a part of the .Net community in Richmond for the past six years.
This entry was posted in Development, Development. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>