Friday, January 30, 2009

Check for Memory Leaks in your SharePoint API Code


Microsoft has just released a memory leak checker for SharePoint code. Not sure if all your SPWeb and SPSite objects have been properly disposed? Use this tool to discover which lines of your code are not properly disposing of those objects.


Each SPWeb and SPSite object takes 1-2 megs of unmanaged memory. So no properly disposing of them causes major memory leaks. However, (this is important) if you dispose of a SPSite object that you get from SPContext.Current, you will crash your SharePoint site. So having a tool that you can run to definitively determine if your production code is good, is a big help.



No comments: