snoyberg/conduit — pull request #41 by takano-akio (2012-04-12 08:41:14+00:00)
Title: Work around a memory leak in 'sequence'

The first testcase posted https://github.com/snoyberg/conduit/issues/40 still leaks with the current HEAD, compiled with ghc-7.4.1 -O2. I think the problem is that full-laziness transformation done by GHC transforms the definition of 'sequence' to a leaky form. Putting {-# OPTIONS_GHC -fno-full-laziness #-} at the top of Data.Conduit.Util.Conduit fixes the problem.

Here is a link to a glasgow-haskell-users thread that mentions the issue: http://www.haskell.org/pipermail/glasgow-haskell-users/2011-February/019997.html

I think this should ideally fixed by fixing GHC, but in the above thread Simon Peyton Jones says it's difficult. So I suppose it might be a good idea to explicitly work around it in conduit.

The commit works around the problem by making the top-level definition non-recursive. Other functions might suffer from a similar problem but I have not checked.