Renowned SharePoint trainer, author, and consultant, Sahil Malik has just posted a new video at Pluralsight OnDemand! on how to debug a SharePoint application with .NET Reflector Pro.
For those of you who don't know what .NET Reflector Pro is: it's a Visual Studio Add-in that allows you to decompile and debug third-party assemblies. So essentially, you can debug SharePoint as if you had the source code. You can step through the code, set breakpoints, etc.
This video is absolutely awesome, I even learnt some new debugging tips! He uses the tool in ways that I hadn't previously - e.g. setting a breakpoint to identify dynamically all callers of a method.
Towards the end, Sahil explains how forgetting to call or incorrectly calling Dispose() on SharePoint's objects is a common problem in SharePoint development and leads to memory leaks. He talks about how the Microsoft tool SPDisposeCheck makes a best effort at analysing your code to follow Microsoft's Best Practices but reports many false positives. He then continues to neatly show how you can use Reflector Pro to accurately zero in on all the situations where you may have forgotten to dispose objects.
In a nutshell, this is a video packed with useful content in just over 20 minutes - well worth watching!
Watch the video here