次の方法で共有


Automate SharePoint Dispose() code reviews with SPDisposeCheck

Today the Microsoft SharePoint Product Team announced the SPDisposeCheck utilityhere and also at Paul Andrew’s blog here. You can download the free SPDisposeCheck utility in the MSDN Code Gallery https://code.msdn.microsoft.com/SPDisposeCheck .

The SPDisposeCheck utility will assist you dig through your custom SharePoint MSIL assemblies (DLL’s and EXE’s) looking for areas in your code that may require “closer examination” and might lead to Dispose() related memory leaks.  It’s important to note that this tool is not a replacement for developers to learn and understand the ins and outs of the SharePoint Dispose() guidance and how it is implemented in their custom code.  A manual code review is still required to cast out ‘false positives’ that the tool may produce in the output report.  During internal field tests we received feedback that the tool can help identify areas in the code that may have been overlooked even by the most experienced SharePoint developers. As a final step in development we encourage you to frequently review your ULS logs for Dispose() related leaks that have occurred while the code is executing.  Note SharePoint’s instrumentation writes to the ULS logs when it finds SPSite and SPWeb objects that were not disposed as expected.

The original MSDN article Best Practices: Using Disposable Windows SharePoint Services Objects was updated 1/30/09 and the Dispose() guidance is in sync with the content on this blog and the SPDisposeCheck tool.  If you have not done so in a while check out my original blog post “SharePoint 2007 and WSS 3.0 Dispose Patterns by Example” which has several updated Dispose() guidance and edge cases including RootWeb and ParentWeb changes.  You can find all the source code examples on this blog in the Visual Studio 2008 solution SPDisposeExamples packaged with the SPDisposeCheck utility installer.

Understanding the latest Dispose() guidance from Microsoft, scanning with SPDisposeCheck frequently throughout the Software Development Life Cycle (SDLC), and examining the SharePoint ULS logs for evidence of Dispose() related leaks during runtime can help you reduce the probability of unnecessary memory pressure resulting in poor performing SharePoint applications.

Comments

  • Anonymous
    January 29, 2009
    PingBack from http://blog.a-foton.ru/index.php/2009/01/30/automate-sharepoint-dispose-code-reviews-with-spdisposecheck/

  • Anonymous
    February 16, 2009
    Hi there, ive just develop a wrapper to use with SPDisposeCheck Tool, that displays Xml with errors if so, and its to be used on VisualStudio postbuild events to prevent bad disposal of Moss objects. I hope it helps someone in a need. http://www.codeplex.com/MossSnips2 Best Regards Scoutman, a portuguese connection Rodrigo Pinto, Sharepoint Solution Architect email:stationsolutions@gmail.com im:workstationpt@hotmail.com

  • Anonymous
    May 16, 2009
    Olen varemgi kirjutanud kui tähtis on SharePointis objektide nagu SPSite, SPWeb ja publishing objektide