Missing Dispose ?

Jan 25, 2010 at 8:58 AM

Hello,

Thank you and congratulation for this tool.

I use SPDisposeCheck tool on your latest release and it returns me following errors :

ID: SPDisposeCheckID_110
Module: ConnectedLookupField.dll
Method: MayaIntl.SharePoint.ApplicationPages.Common.Utility.GetWeb(System.Web.Ht
tpContext,System.String)
Statement: local1 := new Microsoft.SharePoint.SPSite(siteUrl)
Notes:   Disposable type not disposed: Microsoft.SharePoint.SPSite
         ***This may be a false positive depending on how the type was created o
r if it is disposed outside the current scope
More Information: http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-20
07-and-wss-3-0-dispose-patterns-by-example.aspx#SPDisposeCheckID_110
----------------------------------------------------------


ID: SPDisposeCheckID_120
Module: ConnectedLookupField.dll
Method: MayaIntl.SharePoint.ApplicationPages.Common.Utility.GetWeb(System.Web.Ht
tpContext,System.String)
Statement: local0 := local1.{Microsoft.SharePoint.SPSite}OpenWeb()
Notes:   NOTE: This instance was returned from the method and can likely be igno
red as long as the type is disposed in the caller.
         SPDisposeCheck will automatically determine if the instance was dispose
d in the calling method
         Disposable type not disposed: Microsoft.SharePoint.SPWeb
         ***This may be a false positive depending on how the type was created o
r if it is disposed outside the current scope
More Information: http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-20
07-and-wss-3-0-dispose-patterns-by-example.aspx#SPDisposeCheckID_120
----------------------------------------------------------

These warnings come from following function :

        internal static SPWeb GetWeb(HttpContext context, string siteUrl)
        {
            SPWeb web;
            if (string.IsNullOrEmpty(siteUrl))
            {
                web = SPControl.GetContextWeb(context);
            }
            else
            {
                SPSite site = new SPSite(siteUrl);
                web = site.OpenWeb();
            }
            return web;
        }

It seems that the else part contains SharePoint objects that are never been disposed.

Are they false positive and disposed in other function ?

 

Thanks for your answer.

Best Regards

Pierre-Alexandre FLECHE

Coordinator
Jan 25, 2010 at 12:00 PM

Agreed, there is an issue. This is on my todo list. No ETA though.

Leonid

Jan 25, 2010 at 12:54 PM

Ok thank you for your answer.

I think i'm not concerned because source list and destination list are in the same site.

but i just wanna be sure.

Pierre-Alexandre FLECHE