[Haskell-cafe] Space leak with recursion

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Fri Apr 24 09:15:31 UTC 2015


On Fri, Apr 24, 2015 at 10:04:06AM +0100, Tom Ellis wrote:
> In that case the most important thing to do is to try to reproduce the space
> leak without the snapshot socket.

In fact I think we can already deduce the answer from the implementation of
`poll`:

    http://hackage.haskell.org/package/zeromq4-haskell-0.6.3/docs/src/System-ZMQ4.html#poll

The key point is that the [Poll s m] list is `mapM`ed over.  Each handler is
checked for a match and then fired or not fired before the next handler is
checked for a match.  This means that if you call `pollSockets` in a handler
you are leaking the space associated with the unprocessed entries.

Tom


More information about the Haskell-Cafe mailing list