Memory Leak when using DirectorySearcher.FindAll()

前端 未结 5 1549
孤街浪徒
孤街浪徒 2020-12-05 13:46

I have a long running process that needs to do a lot of queries on Active Directory quite often. For this purpose I have been using the System.DirectoryServices namespace, u

5条回答
  •  广开言路
    2020-12-05 14:41

    Found a quick and dirty way around this.

    I had a similar issue in my program with memory growth but by changing .GetDirectoryEntry().Properties("cn").Value to

    .GetDirectoryEntry().Properties("cn").Value.ToString with a if before hand to make sure .value was not null

    i was able to tell GC.Collect to get rid of the temporary value in my foreach. It looks like the .value was actually keeping the object alive rather then allowing it to be collected.

提交回复
热议问题