MailboxProcessor Scan memory leak

108 Views Asked by At

Consider the following agent which uses Scan to process every message, with a message posted every millisecond.

open System.Threading

let mp = MailboxProcessor<string>.Start (fun inbox ->
    let rec await () = inbox.Scan (fun msg ->
        printfn "Received : %s" msg
        printfn "Queue length: %i" inbox.CurrentQueueLength
        Some <| await ())
    await ())
while true do
    mp.Post "word"
    Thread.Sleep 1

If I monitor the memory usage of the process (macOS, via Activity Monitor), it grows and grows. Yet you can see from the printout that the queue length remains at 0.

Is this a memory leak bug in Scan or am I doing something wrong?

0

There are 0 best solutions below

Related Questions in F#