RE: Haskell-beginners problem with memory consuption

2 Oct
2003
2 Oct
'03
9:34 a.m.
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. Cheers, Simon
7948
Age (days ago)
7948
Last active (days ago)
0 comments
1 participants
participants (1)
-
Simon Marlow