I have updated my code as per suggestions from suggestions on my earlier question , I still see the error message for one of my recursive function.
Below is the code snippet to recursively loop through all Webs/Sub-Webs:-
private void IterateLists(SPWeb web, ArrayList _lists)
{
//Add information ablout all the lists and Last Modified dates
foreach (SPList thisList in web.Lists)
{
if (!(thisList.Hidden) && (thisList.Title != _userInformationList))
{
//Add the list information onto the Lists collection
_lists.Add(new ListInfo { WebUrl = web.Url, ListName = thisList.Title, LastModified = thisList.LastItemModifiedDate.ToLocalTime(), TimeDelta = SPUtility.TimeDeltaAsString(thisList.LastItemModifiedDate.ToLocalTime(), DateTime.Now.ToLocalTime()), });
}
//Call this method recursively if this web has subwebs
foreach (SPWeb subWeb in web.Webs)
{
try
{
IterateLists(subWeb, _lists);
}
finally
{
if (subWeb != null)
subWeb.Dispose();
}
}
}
}
it has the code to dispose the subWeb object in the finally block. I have a huge SharePoint web application with many sites and sub sites. I see following error for this particular method.
Potentially excessive number of SPRequest objects (2859) currently unreleased on thread 9. Ensure that this object or its parent (such as an SPWeb or SPSite) is being properly disposed. This object is holding on to a separate native heap. Allocation Id for this object: {9379E575-1358-4D65-B798-7B81EE167112} Stack trace of current allocation: