Expand Minimize

Memory Disposal

Rules to warn for potential memory leaks due to wrong object disposal.

Index

Rule Description Type Severity
SPC110201: Dispose created SPSite objects When you create a SPSite object with a new operator, the creating application must dispose of it. Assembly CriticalWarning
SPC110203: Dispose SPWeb objects created with SPSite.OpenWeb The OpenWeb method create an SPWeb object and return it to the caller. This new object is not stored in the SPSite object and is not disposed of anywhere in the SPSite class. For this reason, you should dispose of any object created via these methods. Assembly CriticalWarning
SPC110204: Dispose SPSite objects created with SPSite.SelfServiceCreateSite The SelfServiceCreateSite method (all signatures) create an SPWeb object and return it to the caller. This new object is not stored in the SPSite object and is not disposed of anywhere in the SPSite class. For this reason, you should dispose of any object created via these methods. Assembly CriticalWarning
SPC110205: Dispose SPWeb created by SPLimitedWebPartManager The SPLimitedWebPartManager class contains a reference to an internal SPWeb object that must be disposed. Assembly Warning
SPC110211: Dispose SPSite created by SPSiteCollection.Add The SPSiteCollection.Add method creates and returns a new SPSite object. You should dispose of any SPSite object returned from the SPSiteCollection.Add method. Assembly CriticalWarning
SPC110212: Dispose SPSite created by SPSiteCollection[] index operator The SPSiteCollection [] index operator returns a new SPSite object for each access. An SPSite instance is created even if that object was already accessed. Assembly CriticalWarning
SPC110213: Dispose SPWeb created by SPWebCollection.Add The SPSite.AllWebs.Add method and SPWebCollection.Add method creates and returns an SPWeb object. You should dispose of any SPWeb object returned. Assembly CriticalWarning
SPC110214: Dispose SPWeb created by SPWebCollection[] index operator The SPSite.AllWebs[] and SPWebCollection[] index operator returns a new SPWeb instance each time it is accessed. An object is created during the indexing operation even if that object was already accessed. Assembly CriticalWarning
SPC110231: Do not dispose SPListEventProperties.Web The SPWeb object in SPListEventProperties (e.g. used in a SPListEventReceiver) should not be disposed. Assembly CriticalWarning
SPC110232: Do not dispose SPWebEventProperties.Web The SPWeb object in SPWebEventProperties (e.g. used in a SPWebEventReceiver) should not be disposed. Assembly CriticalWarning
SPC110233: Do not dispose SPItemEventProperties.Web The SPWeb object in SPItemEventProperties (e.g. used in a SPItemEventReceiver) should not be disposed. Assembly CriticalWarning
SPC110234: Do not dispose SPItemEventProperties.ListItem.Web The object in SPItemEventProperties.ListItem.Web (e.g. used in a SPItemEventReceiver) should not be disposed. Assembly CriticalWarning
SPC110235: Do not dispose SPItemEventProperties.Web.Site The object in SPItemEventProperties.Web.Site (e.g. used in a SPItemEventReceiver) should not be disposed. Assembly CriticalWarning
SPC110236: Do not dispose SPItemEventProperties.ListItem.Web.Site The object in SPItemEventProperties.ListItem.Web.Site (e.g. used in a SPItemEventReceiver) should not be disposed. Assembly CriticalWarning
SPC110237: Do not dispose SPFeatureReceiverProperties.Feature.Parent The object in SPFeatureReceiverProperties.Feature.Parent (e.g. used in a SPFeatureReceiver) should not be disposed. Assembly CriticalWarning
SPC110241: Do not dispose SPSite.RootWeb An earlier version of the documentation indicated that the calling application should dispose of the SPSite.RootWeb property just before disposing of the SPSite object that is using it. This is no longer the official guidance. The dispose cleanup is handled automatically by the SharePoint framework. Assembly CriticalWarning
SPC110242: Do not dispose SPWeb.ParentWeb An earlier version of the documentation recommended that the calling application should dispose of the SPWeb.ParentWeb. This is no longer the official guidance. The dispose cleanup is handled automatically by the SharePoint framework. Assembly CriticalWarning
SPC110243: Do not dispose SPList.ParentWeb An earlier version of the documentation recommended that the calling application should dispose of the SPWeb.ParentWeb. This is no longer the official guidance. The dispose cleanup is handled automatically by the SharePoint framework. Assembly CriticalWarning
SPC110244: Do not dispose SPSite returned by SPControl.GetContextSite If SPSite is obtained from the SharePoint context objects (GetContextSite method), the calling application should not call the Dispose method on the object. Assembly CriticalWarning
SPC110245: Do not dispose SPWeb returned by SPControl.GetContextWeb If SPWeb is obtained from the SharePoint context objects (GetContextWeb method), the calling application should not call the Dispose method on the object. Assembly CriticalWarning
SPC110246: Do not dispose SPSite returned by SPContext.Current.Site SPContext objects are managed by the SharePoint framework and should not be explicitly disposed in your code. This is true also for the SPSite objects returned by SPContext.Site and SPContext.Current.Site Assembly CriticalWarning
SPC110247: Do not dispose SPWeb returned by SPContext.Current.Web SPContext objects are managed by the SharePoint framework and should not be explicitly disposed in your code. This is true also for the SPWeb objects returned by SPContext.Web and SPContext.Current.Web Assembly CriticalWarning
SPC110261: Close PublishingWeb created by PublishingWeb.GetPublishingWebs[] index operator The GetPublishingWebs method of the PublishingWeb class returns a PublishingWebCollection object. You must call the Close method on each enumerated innerPubWeb object. When you are calling only the GetPublishingWeb method, you are not required to call Close. Assembly CriticalWarning
SPC110262: Close PublishingWeb created by PublishingWeb.GetVariation The Microsoft.SharePoint.Publishing.PublishingWeb.GetVariation method returns a PublishingWeb object that must be closed. Assembly CriticalWarning
SPC110263: Close PublishingWeb created by PublishingWebCollection.Add PublishingWebCollection.Add() method requires you to call Close on the returned PublishingWeb object. Assembly CriticalWarning
SPC110281: Dispose SPSite created with UserProfiles.PersonalSite The Microsoft.Office.Server.UserProfiles.PersonalSite returns an SPSite object that must be disposed. Assembly CriticalWarning
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.