Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

memory leaks in Microsoft.FSharp.Control.Mailbox?

I'm hunting for some memory-leaks in a long runing service (using F#) right now. The only "strange" thing I've seen so far is the following:

  • I use a MailboxProcessor in a subsystem with an algebraic-datatype named QueueChannelCommands (more or less a bunch of Add/Get commands - some with AsyncReplyChannels attached)
  • when I profile the service (using Ants Memory Profiler) I see instances of arrays of mentioned type (most having lenght 4, but growing) - all empty (null) whose references seems to be held by Control.Mailbox: enter image description here

I cannot see any reason in my code for this behaviour (your standard code you can find in every Mailbox-example out there - just a loop with a let! = receive and a match to follow ended with a return! loop()

Has anyone seen this kind of behaviour before or even knows how to handle this? Or is this even a (known) bug?

Update: the growing of the arrays is really strange - seems like there is additional space appended without beeing used properly: enter image description here

like image 715
Random Dev Avatar asked Sep 10 '25 01:09

Random Dev


1 Answers

I am not a F# expert by any means but maybe you can look at the first answer in this thread:

Does Async.StartChild have a memory leak?

The first reply mentions a tutorial for memory profiling on the following page:

  • http://moiraesoftware.com/blog/2011/12/11/fixing-a-hole/

But they mention this open source version of F#

  • https://github.com/fsharp/fsharp/blob/master/src/fsharp/FSharp.Core/control.fs

And I am not sure it is what you are looking for (about this open source version of F# in the last point), but maybe it can help you to find the source of the leak or prove that it is actually leaking memory.

Hope that helps somehow maybe ?

Tony

like image 120
BlueTrin Avatar answered Sep 15 '25 23:09

BlueTrin