1 minute read

Update: A new version of the tool is available as you can read here

On the internet you can find several excellent articles on the various design patterns for disposing of SharePoint or WSS objects.
Some of these objects can cause serious memory leaks if you don’t use them correctly. Normally you have to take care of three different objects: SPSite, SPWeb and Publishing.

There are a couple of White Papers available on MSDN that you can read about this subject:

Best Practices: Using Disposable Windows SharePoint Services Objects
Best Practices: Common Coding Issues When Using the SharePoint Object Model.

Yesterday a tool was released for checking if you dispose of the objects in a correct way. The tool is called SPDisposeCheck. SPDisposeCheck is a tool to help you check your assemblies that use the SharePoint API so that you can build better code. The tool may not show all memory leaks and further investigation is advised if you continue to experience issues.

spdisposecheck

You can download SPDisposeCheck here.

I checked the tool out by applying it to one of our project and we found 21 problems. We fixed those problems and we certainly saw an improvement. So try this tool out and let it help you with building better code.