Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

An SPRequest object was reclaimed by the garbage collector ...

$
0
0

I recently discovered this error popping up in the ULS logs; I searched the internet and managed to get rid of most of these messages.

Still there is this one left. Basicaly it's about deleting an item from a documentlibrary after it's been copied to anther library on another site (amongst other actions).

I have ended up with a very minimalistic webpart that does just that: deleting an item from a list.

Here is the full code of that webpart:

using System;
using System.ComponentModel;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;

namespace VerwijderListitemWebpart.VerwijderListitemWebpart
{
   [ToolboxItemAttribute(false)]
   public class VerwijderListitemWebpart : WebPart
   {
      protected override void CreateChildControls()
      {
         LinkButton submitButton = new LinkButton();
         submitButton.Text = "Delete 1st item";
         submitButton.Click += new EventHandler(submitButton_Click);
         this.Controls.Add(submitButton);
      }

      void submitButton_Click(object sender, EventArgs e)
      {
         string msg = "Ok .. done";
         try
         {
            using (SPSite site = new SPSite("http://bimserverarjen:100/PDs"))
            {
               using (SPWeb web = site.OpenWeb())
               {
                  SPList list = web.Lists["GV"];
                  SPListItem itm = list.Items[0];
                  itm.Delete();
               }
            }
         }
         catch (Exception ex)
         {
            msg = "Error: " + ex.Message;
         }
         Label l = new Label();
         l.Text = "<br />" + msg;
         this.Controls.Add(l);
      }
   }
}

I run the ULSviewer at the same time and filter the messages for EventID 'nask'. When I Click the submitbutton, the first element in the library is deleted; all conform the supposed design patterns with regards to disposing objects in the right way.I still get the message in teh ULSlogs though:

An SPRequest object was reclaimed by the garbage collector instead of being explicitly freed.  To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it.  Allocation Id: {AEFCF6AB-36A5-4F86-AE69-A96A7B2E4A19}  This SPRequest was allocated
 at   
 at Microsoft.SharePoint.Library.SPRequest..ctor()    
 at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)    
 at Microsoft.SharePoint.SPWeb.InitializeSPRequest()    
 at Microsoft.SharePoint.SPListCollection.EnsureListsData(Guid webId, String strListName)    
 at Microsoft.SharePoint.SPListCollection.ItemByInternalName(String strInternalName, Boolean bThrowException)    
 at Microsoft.SharePoint.SPItemEventProperties.get_List()    
 at Microsoft.SharePoint.SPItemEventProperties.get_ListItem()    
 at Microsoft.SharePoint.Publishing.Internal.PublishingWebEventReceiver.AbortDeleteOfDefaultPage(SPItemEventProperties properties)    
 at Microsoft.SharePoint.Publishing.Internal.PublishingWebEventReceiver.ItemDeleting(SPItemEventProperties properties)    
 at Microsoft.SharePoint.SPEventManager.RunItemEventReceiver(SPItemEventReceiver receiver, SPUserCodeInfo userCodeInfo, SPItemEventProperties properties, SPEventContext context, String receiverData)    
 at Microsoft.SharePoint.SPEventManager.RunItemEventReceiverHelper(Object receiver, SPUserCodeInfo userCodeInfo, Object properties, SPEventContext context, String receiverData)    
 at Microsoft.SharePoint.SPEventManager.<>c__DisplayClassc`1.<InvokeEventReceivers>b__6()    
 at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, Boolean bResetContext, WaitCallback code, Object param)    
 at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](SPUserToken userToken, Guid tranLockerId, RunEventReceiver runEventReceiver, Object receivers, Object properties, Boolean checkCancel)    
 at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](Byte[] userTokenBytes, Guid tranLockerId, RunEventReceiver runEventReceiver, Object receivers, Object properties, Boolean checkCancel)    
 at Microsoft.SharePoint.SPEventManager.ExecuteItemEventReceivers(Byte[]& userToken, Guid& tranLockerId, Object& receivers, ItemEventReceiverParams& itemEventParams, Object& changedFields, EventReceiverResult& eventResult, String& errorMessage)    
 at Microsoft.SharePoint.Library.SPRequestInternalClass.DeleteItem(String bstrUrl, String bstrListName, Int32 lID, UInt32 dwDeleteOp, Guid& pgDeleteTransactionId)    
 at Microsoft.SharePoint.Library.SPRequest.DeleteItem(String bstrUrl, String bstrListName, Int32 lID, UInt32 dwDeleteOp, Guid& pgDeleteTransactionId)    
 at Microsoft.SharePoint.SPListItem.DeleteCore(DeleteOp deleteOp)    
 at Microsoft.SharePoint.SPListItem.Delete()    
 at VerwijderListitemWebpart.VerwijderListitemWebpart.VerwijderListitemWebpart.submitButton_Click(Object sender, EventArgs e)    

So it states that my code initiated some leak, but I have no clue what I can change in the code to prevent this ... and yes, I did read lots of articles about disposing obecjts and such, and I have used SPDisposeCheck.

On a side note: when running the actual code that deletes the item from a windows console clientprogramme, there is no message popping up in the ULS ...

thanks for any clues or help 


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>