zoukankan      html  css  js  c++  java
  • SharePoint How To:定位错误:“An SPRequest object was not disposed .."

    我们的Sharepoint程序有时泄露了很多SPWeb,SPSite对象,SharePoint日志中就会有很多错误信息,如下:

       

    An SPRequest object was not disposed before the end of this thread. 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. This object will now be disposed. Allocation Id: {5E41622E-AFA6-44E4-AAB3-809A70D39CCA} To determine where this object was allocated, set Microsoft.SharePoint.Administration.SPWebService.ContentService.CollectSPRequestAllocationCallStacks = true(线索).

       

    如果您细心地话,您会发现上面日志中提到了一个参数,按照要求设置后就可以看到完整的CallStacks

       

    An SPRequest object was not disposed before the end of this thread. 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. This object will now be disposed. Allocation Id: {A635DEED-3786-40C7-BA42-6D3E3CB4571B} 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.SPFieldCollection.EnsureFieldsSafeArray(Boolean bGetFullXML)

    at Microsoft.SharePoint.SPFieldCollection.get_DisplayNameDict()

    at Microsoft.SharePoint.SPFieldCollection.GetFieldByDisplayName(String strDisplayName, Boolean bThrowException)

    at SharePointBoost.Workflow.Common.WorkflowRepository.GetItems(SPList list, Hashtable condition)

    at SharePointBoost.Workflow.Common.WorkflowRepository.GetWorkflow(String workflowId, VersionType version)

    at SharePointBoost.Workflow.Layouts.ApplicationPages.WorkflowDesigner.CreateWorkflowDesigner(String workflowID, VersionType version)

    at SharePointBoost.Workflow.Layouts.ApplicationPages.WorkflowDesigner.Page_Load(Object sender, EventArgs e)

    at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)

    at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)

    at System.Web.UI.Control.OnLoad(EventArgs e)

    at Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.OnLoad(EventArgs e)

    at Microsoft.SharePoint.WebControls.LayoutsPageBase.OnLoad(EventArgs e)

    at System.Web.UI.Control.LoadRecursive()

    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    at System.Web.UI.Page.ProcessRequest()

    at System.Web.UI.Page.ProcessRequest(HttpContext context)

    at ASP._layouts_sharepointboost_workflow_workflowdesigner_aspx.ProcessRequest(HttpContext context)

    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

    at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)

    at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)

    at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)

    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)

    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)

    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)

    at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)

       

    运行下面的的Power Shell代码设置Microsoft.SharePoint.Administration.SPWebService.ContentService.CollectSPRequestAllocationCallStacks。(如果没用过Power Shell,参考:http://technet.microsoft.com/en-us/library/ee176949.aspx 

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

    [System.Reflection.Assembly]::LoadFile($Env:CommonProgramFiles+"\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.dll") | out-null

       

    # Get Content Service of the farm

    $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService

       

    # Display and change the setting of property "CollectSPRequestAllocationCallStacks"

    write-host "Current: " $contentService.CollectSPRequestAllocationCallStacks

    $contentService.CollectSPRequestAllocationCallStacks = $true

    $contentService.Update()

       

    write-host " New: " $contentService.CollectSPRequestAllocationCallStacks

       

       

       

       

       

  • 相关阅读:
    a[::-1]相当于 a[-1:-len(a)-1:-1],也就是从最后一个元素到第一个元素复制一遍。
    +=
    map 和reduce
    赋值语句
    高阶函数
    函数式编程
    迭代器
    如何判断一个对象是可迭代对象呢?方法是通过collections模块的Iterable类型判断:
    ie11升级的过程中遇到的问题以及解决办法
    .csporj 文件部分节点解析
  • 原文地址:https://www.cnblogs.com/osamede/p/2222363.html
Copyright © 2011-2022 走看看