Our DNN 4.8.4 intranet was eating up a huge chunch of memory on the server. The IIS proces (w3wp.exe) would grow to about 900 megs, then the process would restart itself. We engaged Microsoft Premier Support, and they came back with the following discovery/suggestion:
While analyzing the dumps which had been taken by our IIS engineers, I found the calls are hanging/waiting on System.DirectoryServices API.
I further researched on that dump and found one of the classes which is using S.DirectoryServices API is “DotNetNuke.Authentication.*” and the method currently the application is in hang state is “DotNetNuke.Authentication.ActiveDirectory.ADSI.Search.GetEntries()”.
The class in this method we are using is “SearchResultCollection” and we are not Dispoing this object. If you look at the remarks section in the http://msdn.microsoft.com/en-us/library/system.directoryservices.searchresultcollection.aspx you will find the following quote:
Due to implementation restrictions, the SearchResultCollection class cannot release all of its unmanaged resources when it is garbage collected. To prevent a memory leak, you must call the Dispose method when the SearchResultCollection object is no longer needed.
I will suggest first of all we need to Dispose the object used for this class. Also as a best programming practices for System.DirectoryServices API we need to call Close() & Dispose() for DirectoryEntry objects and Dispose() of SearchResultCollection, Dispose() of DirectorySearcher class objects.
I thought the suggested changes might be an important thing to roll into the production code, since it would likely impact all users.