How to debug Potentially excessive number of SPRequest objects error message

You may have seen this error message in your SharePoint log file.

Potentially excessive number of SPRequest objects (10) currently unreleased on thread 5. Ensure that this object or its parent (such as an SPWeb or SPSite) is being properly disposed. This object will not be automatically disposed.

Now this means that you have some (custom) code in your SharePoint installation that doesn’t dispose its memory allocation correctly. You have code that leak memory.

The error message in the log doesn’t say much on where this memory leak happens, which makes it a little bit difficult to trouble shoot. However, there is a way to tell SharePoint to tell you more on where this happens by also writing out the stack trace in the log file.

Open RegEdit and browse to the

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\HeapSettings key. Edit the SPRequestStackTrace DWORD Entry and set it to 1.

You will now geta full stack trace whenever this error message appears, which makes it so much easier to trouble shoot.

This post is licensed under CC BY 4.0 by the author.