Search Wiki:
Resource Page Description
SPDisposeCheck is a tool to help you to check your assemblies that use the SharePoint API so that you can build better code. It provides assistance in correctly disposing of certain SharePoint objects to help you follow published best practice. This tool may not show all memory leaks in your code. Further investigation is advised if you continue to experience issues.

SPDisposeCheck.exe takes the path to a managed .DLL or .EXE or the path to a directory containing many managed assemblies. It will recursively search for and analyze each managed module attempting to detect coding patterns based on the MDSN article.


Please review the MSDN article on using Deploy in SharePoint applications here

The SPDisposeCheck tool can be downloaded here.

Roger Lamb maintains a blog for the SPDisposeCheck team here.

Note: The -xml command line switch is unreliable. We recommend that you do not use this command line switch on this release.
Last edited Jan 30 2009 at 6:57 PM  by pandrew, version 3
Comments
colbyafrica wrote  Jan 29 2009 at 7:45 PM  
Nice!

Anubhav wrote  Jan 30 2009 at 6:20 AM  
Really helpful. Thanks.

Jomit wrote  Jan 30 2009 at 9:27 AM  
Nice tool indeed ! I just posted this on my blog : http://jomit.blogspot.com/2009/01/disposing-sharepoint-2007-and-wss-30.html

But I am having troubles exporting the output to xml ? I tried it with the sample code itself but it just throws some error....

Carol wrote  Jan 30 2009 at 2:14 PM  
Great tool!

However, I have the same trouble with XML output. I tried on assembly where some errors were found and also on clean assembly. The -xml switch trows an exception on both case.

vaibhavmathur wrote  Jan 30 2009 at 4:31 PM  
The tool encounters problem when trying to output xml to a file. Throws the error while trying to "Processing Method Traces..."

ShivaSK wrote  Jan 30 2009 at 10:00 PM  
Having same problem :(

cakriwut wrote  Jan 31 2009 at 3:52 AM  
I have problem with xml option. However it just nice anyway - http://blog.libinuko.com/2009/01/31/a-new-born-tool-sharepoint-dispose-checker/

michhes wrote  Feb 1 2009 at 4:51 AM  
The tool runs fine without the -xml param... just leave it off and pipe the output to a text file instead (refer note above).

Smeikkie wrote  Feb 2 2009 at 7:58 AM  
Great tool: I posted a topic on my blog http://www.blogaboutsharepoint.com
keep up the good work. only writing to a xml file does not work.

bdoc7mcg wrote  Feb 2 2009 at 9:57 PM  
Nice! I also had the XML issue, but piping to a file from the command line worked find for me.
SPDisposeCheck.exe "c:\my folder" >disposecheck.txt

dmcwee wrote  Feb 23 2009 at 4:45 PM  
Great tool, any chance a "black box" dll could be released so it could be integrated with MSBuild tasks?

DGL wrote  Feb 26 2009 at 2:24 PM  
Great Tool, ¡¡cool man!!.

RichardWillis wrote  Feb 26 2009 at 11:55 PM  
I'm the project co-ordinator for the SharePoint Learning Kit at http://www.codeplex.com/slk. I'd love to use SPDisposeCheck on it, but it check to see if the file name begins with Microsoft (it does) and then if I rename the file, if any namespace begins with Microsoft (they all do) and then skips the assembly. Is there any possibility of adding an option to not skip Microsoft assemblies. And before you ask, we can't change the namespaces as it was originally a Microsoft project and it would break all existing installations.
Thanks,
Richard

GandeVijay wrote  Jul 29 2009 at 1:38 PM  
Nice tool, the -xml option did not work.

Bram wrote  Sep 2 2009 at 2:47 PM  
The tool works like a charm and really provides usefull feedback. Although I tried to implement the SPDisposeCheckIgnoreAttribute in my own project within the namespace MyApplication.DisposeCheck.SPDisposeCheckIgnoreAttribute. If I got it right this is mentioned in the SPDispose_Readme.rtf of the SPDisposeCheck tool. It seems after using reflection it checks on the System.Attribute.Type.FullName == "SPDisposeCheck.SPDisposeCheckIgnoreAttribute". Meaning the fullname needs to be equal to SPDisposeCheck.SPDisposeCheckIgnoreAttribute and can't contain your own namespace.

I added an issue for this. Does anyone else have the same or related experience?
Thanks,
Bram

StephenDVick wrote  Jan 6 at 3:54 PM  
To see how to run SPDisposeCheck as a build task and automated unit test that can be applied to a check in policy see:

http://stephenvick.wordpress.com/2010/01/06/run-spdisposecheck-as-build-task-and-automated-unit-test/


-Vick

Updating...
Page view tracker