Memory Leak in DirectoryQuery.GetResults()


The following line causes a memory leak:
"foreach (SearchResult sr in s.FindAll())"
The reason for this can be found here:
Ultimately, any time you use a SearchResultCollection object (such as when you call DirectorySearcher.FindAll), you must dispose the SearchResultCollection object yourself. A fix would be to put the s.FindAll() result into a variable managed by a USING block.


jaxidian wrote Mar 18, 2010 at 7:13 PM

Had wrong class name.

bdesmet wrote Jul 16, 2010 at 7:06 AM

Will be addressed in an upcoming release.

wrote Jun 4, 2011 at 1:32 PM

wrote Feb 14, 2013 at 6:56 PM