Checking your SharePoint code for Memory Leaks
I have been writing custom code for SharePoint sites for several years now. As one knows when writing code testing, testing, testing and a good code review can help to ensure solid code. One of the major issue when writing any SharePoint code is the misuse of the SharePoint API in the failure to Dispose of your objects. As you may guess not disposing, especially with the SharePoint API, can cause memory leaks which you will pay for dearly over time. Well one tool that can aid with ensuring that you catch some of these potential memory leaks is a tool called SPDisposeCheck. It is a command line tool which will allow you to give a path for a set of DLLs and then recursively check all DLLs in the path for violations of the SPDispose best practices as outlined on MSDN. The tool is quick and easy to run and spits out the violations to your console. A quick use of the “>>” operator however will allow one to save this to a text file which can then be shared if necessary. This tool should be a key piece of any SharePoint Developer’s tool set.
Roger Lamb has a great article, and maintains a SharePoint Developer Blog, on many of the patterns and best practices which should be used when leveraging the SharePoint API in your code. You can check out Roger’s blog and article here.
Happy and Safe SharePoint Coding!