[Haskell-cafe] Space leak with recursion
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Fri Apr 24 09:04:06 UTC 2015
On Fri, Apr 24, 2015 at 10:57:41AM +0200, Martijn Rijkeboer wrote:
> > On Fri, Apr 24, 2015 at 10:41:30AM +0200, Martijn Rijkeboer wrote:
> >> > I don't see where you are updating any state.
> >> The state contains a sequence number that needs to be incremented,
> >> but I left that out for brevity...
> > It's important to see that, because that kind of thing is exactly where
> > space leaks can hide.
> Sorry for the confusion. The version that has the space leak is the
> version that I included with my initial mail and doesn't increment
> the sequence number.
> Once thee space leak is fixed I will need to add code to increment the
> sequence number (not yet implemented).
In that case the most important thing to do is to try to reproduce the space
leak without the snapshot socket.
> I tried to make a minimal version that reproduces the problem, but I need
> to be able to update the state in the "real" version.
Very sensible. I was confused for a moment whether the minimal version did
actually exhibit the space leak behaviour.
To get the state-updating behaviour you want, I suggest you use `StateT IO`
rather than `IO`. With handlers in the `StateT IO` monad the state updates
will occur as you expect.
More information about the Haskell-Cafe