SharePoint 2010 – Maggiori dettagli sullo stack trace SPRequest nei log SharePoint 2010

Se nel log di SharePoint vi capitano dei messaggi simili a questi:

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: {929EB2BD-461F-48B3-8D31-CA8C521ED3BB}

e volete avere maggiori informazioni, per individuare qual’è il blocco di codice che causa questo mal utilizzo degli oggetti SPSite e SPWeb, basta creare uno script PowerShell, chiamandolo 

EnableSPRequestCallstacks.ps1

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null 

$contentSvc = [Microsoft.SharePoint.Administration.SPWebService]::ContentService 
$contentSvc.CollectSPRequestAllocationCallStacks = $true 
$contentSvc.Update()

DisableSPRequestCallstacks.ps1 (per disabilitare)

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null 

$contentSvc = [Microsoft.SharePoint.Administration.SPWebService]::ContentService 
$contentSvc.CollectSPRequestAllocationCallStacks = $false 
$contentSvc.Update()

Per eseguire lo script aprire la PowerShell di SharePoint ed eseguire lo script desiderato. PS> .EnableSPRequestCallstacks.ps1 


NB: se cercate di eseguire gli script sopra indicati copiando e incollando il testo dentro la PowerShell di SharePoint non funziona, creare assolutamente dei file “ps1”.


Per maggiori info: Blog di Stefan Gossner

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *