Haskell-beginners problem with memory consuption

Simon Marlow simonmar at microsoft.com
Thu Oct 2 11:34:53 EDT 2003

> Keep in mind that Strings are lists of characters.  I think (somebody
> correct me if I'm wrong) GHC will store a character inside a cons
> cell, but that still leaves 8 bytes per character.  Worst case it will
> store the 8-byte cons cell pointing to a 32-bit char value, 12 bytes
> per character. (Strings as lists-of-char is very useful, but not
> terribly efficient). 

Worst case: 16 bytes per character,  usual case (all characters <=
'\xff'): 8 bytes per character, because we have static copies of
characters 0-255 in the RTS.  Using Data.PackedString or UArray Char: 4
bytes per character.


More information about the Haskell-Cafe mailing list