Should I explicitly clear non-global ConcurrentDictionary when not used anymore, or does GC detect its not used anymore?
This is kind of related: Is ConcurrentBag cause of memory leak?
Edit: The reason I was asking, I had following kind of code (simplified here):
let myMethod() =
async {
let myEventList = ConcurrentDictionary<myEventParams, bool>()
use o = myEvent |> Observable.subscribe(fun e ->
myEventList.GetOrAdd(e, true) |> ignore)
let! res = doAsyncThingsCausingEvents()
myEventList |> Seq.iter(fun (e,_) -> Console.WriteLine "We had " + e.ToString())
res
}
...and indeed it leaked memory when called parallel in multiple threads several times.