iteratee [Haskell] ANN: - and released

John Lato jwlato at
Tue Feb 15 16:50:18 GMT 2011

Hi Jason,

(cc'd to iteratee at

No, I didn't.  When I discovered it I intended to write a bug report in the
Trac instance, but the community server was still having problems so I
couldn't.  I'll try again tonight, but until then here's a quick description
of the memory leak fixed in the most recent point release.

The functions "enumHandle", "enumFd", and variants suffered from a memory
leak.  They allocated a temporary buffer with 'malloc' that was never
free'd.  The current solution uses a combination of
"Control.MonadCatchIO.bracket" and "free" to ensure the memory is released.

Unfortunately this suffers from the short-circuiting monad bug in
MonadCatchIO.  If an iteratee is used with a short-circuiting monad (e.g.
ErrorT), the memory can still fail to be released.

A better solution would be to use "alloca" or a ForeignPtr to obtain and
release the memory automatically, however this will require switching from
MonadCatchIO.  I'm likely to make this switch with the next major release,
however I thought it best to provide a point release that fixes the most
common cases in the interim.

For now, if anyone needs short-circuiting within iteratee, I would recommend
that you use the iteratee in-built exception handling over an 'IO' or other
non-short-circuiting monad stack.


On Tue, Feb 15, 2011 at 3:03 PM, Jason Dagit <dagitj at> wrote:

> Hi John,
> Do you describe this memory leak an the fix anywhere?
> Thanks!
> Jason
> On Thu, Feb 10, 2011 at 2:31 PM, John Lato <jwlato at> wrote:
>> (Apologies for cross-posting)
>> I have recently discovered a memory leak which affects all current
>> versions of iteratee.  I have released iteratee versions and
>> which fixes the memory leak.  I would strongly encourage all users of
>> earlier versions to upgrade to one of these releases.
>> Cheers,
>> John Lato
>> _______________________________________________
>> Haskell mailing list
>> Haskell at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Iteratee mailing list