[Haskell-cafe] Re: Over-allocation

Ketil Malde ketil+haskell at ii.uib.no
Wed Nov 21 09:32:35 EST 2007

Gracjan Polak <gracjanpolak at gmail.com> writes:

> I tried both Map and IntMap and there was no difference in memory total usage or
> usage pattern. Seems I'm already strict enough.

This only proves Map and IntMap are equally strict, or in other words,
they are both lazy in the elements.

> Values are left lazy till the point where they are forced, and that is at
> write-out in my current excersise. I'd want to leave them lazy as in more
> involved transformation not all of them will be needed.

Then you get the memory behavior you ask for.  Unevaluated strings are
extremely expensive, something like 12 bytes per char on 32 bit, twice
that on 64 bits, and then you need GC overhead, etc.  ByteStrings are
much better, but you then probably need to implement your own XML

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list