Dispose Explicitly Called on SPLimitedWebPartManager.Web // SPDisposeCheck error
-
07-10-2020 - |
题
I have used SPDisposeCheck command line utility on following code and it gives comments as
"Dispose Explicitly Called on SPLimitedWebPartManager.Web".
I carefully analyse my code for any potential memory leaks but I don't find any issue and I properly called Dispose method. This is the code which I think handled properly for any memory leak:
private static void MyWebParts(SPListItem sourceItem, SPListItem destinationItem, bool somevariable)
{
SPLimitedWebPartManager sourceWP = sourceItem.File.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
SPLimitedWebPartManager destinationWP = destinationItem.File.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
try
{
Method1(destinationItem, destinationWP, sourceWP);
Method2(sourceItem, destinationItem);
}
catch (Exception err)
{
SPContextManager.Current.LogManager.LogErrorToDevelopers(err);
}
finally
{
destinationWP.Dispose();
sourceWP.Dispose();
}
I have dispose the SPLimitedWebPartManager
Objects and it seems there is no memory leaks, but SPDIsposeCheck command line tool gives this comments:
Dispose Explicitly Called on SPLimitedWebPartManager.Web sourceWP.{Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager}Dispose()
Dispose Explicitly Called on SPLimitedWebPartManager.Web destinationWP.{Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager}Dispose()
Why is that ??