[Haskell-cafe] Space leak - help needed

Luke Palmer lrpalmer at gmail.com
Sun Mar 2 22:03:12 EST 2008

On Mon, Mar 3, 2008 at 2:23 AM, Krzysztof Kościuszkiewicz
<k.kosciuszkiewicz+haskell at gmail.com> wrote:
> Dear Haskellers,
>  Another story from an (almost) happy Haskell user that finds himself
>  overwhelmed by laziness/space leaks.
>  I'm trying to parse a large file (>600MB) with a single S-expression
>  like structure. With the help of ByteStrings I'm down to 4min processing
>  time in constant space. However, when I try to wrap the parse results
>  in a data structure, the heap blows up - even though I never actually
>  inspect the structure being built! This bugs me, so I come here looking
>  for answers.

Well, I haven't read this through, but superficially, it looks like
you're expecting the data structure to be constructed lazily.  But...

>  > -- Syntax of expressions
>  > data Exp = Sym !B.ByteString | List ![Exp]
>  >     deriving (Eq, Show)

It is declared as strict, so it's not going to be constructed lazily...


More information about the Haskell-Cafe mailing list