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

       

       

       

       

       

  • 相关阅读:
    多态的详解
    Java继承详解
    static关键字特点
    数组(相关知识的整理)
    杨辉三角(用for循环)
    Jmeter接口测试案例实践(一)
    组合测试方法:配对测试实践
    用例设计方法:判定表驱动法实践
    sso系统登录以及jsonp原理
    单点登录--sso系统
  • 原文地址:https://www.cnblogs.com/osamede/p/2222363.html
Copyright © 2011-2022 走看看