let mutable run = true
[ for i in 0 .. 1_000_000 ->
MailboxProcessor.Start(fun inbox ->
async { while run do
let! msg = inbox.Receive()
printfn "agent %d got message '%s'" i msg } )]
|> List.iter (fun x -> x.Post "Ping!"; x.Dispose()); run <- false;;
Code above consume memory up to 2GB but after done it memory of dotnet fsi stay 2GB even if I call GC.Collect (). Why?
let f () =
[ for i in 0 .. 1_000_000 ->
MailboxProcessor.Start(fun inbox ->
let mutable run = true
async { while run do
let! msg = inbox.Receive()
run <- false
printfn "agent %d got message '%s'" i msg } )]
|> List.iter (fun x -> x.Post "Ping!"; x.Dispose())
f ()
System.GC.Collect ()
I change code for run explicit stopped but memory still grow.
I check memory via command: