Solved: [Was: Re: [Haskell-cafe] Program with ByteStrings leads to memory exhaust]

Grigory Sarnitskiy sargrigory at
Mon Sep 14 12:49:44 EDT 2009

> I have tweaked this program a few ways for you. 
> The big mistake (and why it runs out of space) is that you take
> ByteString.Lazy.length to compute the block size. This forces the entire
> file into memory -- so no benefits of lazy IO.
> As a separate matter, calling 'appendFile . encode' incrementally for
> each element will be very slow. Much faster to encode an entire list in
> one go.
> Finally, using System.Random.Mersenne is significantly faster at Double
> generation that System.Random.

Thank you! Just excellent! // I'm so happy :-)

More information about the Haskell-Cafe mailing list