All About SharePoint

Liedong(Ken) Zheng,SharePoint Leader at SIMPLOT

Archive for July 6th, 2010

An SPRequest object was not disposed before the end of this thread.

Posted by ken zheng on July 6, 2010

If you use ULS Viewer, you may find soem high messages:

05/01/2007 12:58:47.31 w3wp.exe (0x105C) 0x09A8 Windows SharePoint Services General 8l1n High 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: {5BFFCA4B-3B91-45BF-98CD-0BB508BE30EE} To determine where this object was allocated, create a registry key at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\HeapSettings. Then create a new DWORD named SPRequestStackTrace with the value 1 under this key.

To identify which code is responsible for the problem after you identified the problem you have two options:

1. You can search the earlier ULS logs for the allocation ID in the warning (if the allocation was done beyond the threshold you will find it)

2. You can follow the hints in the warning and set the following registry key as this will ensure that the stack trace of the allocation of the SPRequest object is preserved in memory and added to the 8l1n ULS log entry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\HeapSettings

SPRequestStackTrace = 1

Yes you need to cretae this key “HeapSettings” and the DWORD value below it.

They do not exist after installing the product.

The second option is more reliable as it will ensure that you get a callstack for each of the 8l1n messages. Be aware that after setting this registry key you need to restart the sharepoint services and the application pools (or restart the server) to ensure that the settings get effective.

By analyzing the emitted callstack you should then be able to identify the component causing the problem.

Posted in Sharepoint | Tagged: , | 1 Comment »

How to Use SPDisposeCheck

Posted by ken zheng on July 6, 2010

SPDisposeCheck is a tool to help you to check your assemblies that use the SharePoint API so that you can build better code. It provides assistance in correctly disposing of certain SharePoint objects to help you follow published best practice. This tool may not show all memory leaks in your code. Further investigation is advised if you continue to experience issues.

You can download from CodePlex here.

here is the example show you how to dispose the patterns.

How to use it

1. Install SPDisposeCheck.msi on your development server.
2. Open a command window.
3. Type following command:
“c:\Program Files\Microsoft\SharePoint Dispose Check\SPDisposeCheck.exe” “.dll”

Posted in Sharepoint, Tools | Tagged: , | 1 Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 28 other followers