[Haskell-cafe] why does the binary library require so much memory?

Jeremy Shaw jeremy at n-heptane.com
Fri Jul 31 19:38:16 EDT 2009


I fixed my test program, and now things seem more reasonable. The
original version was allowing the GC to collect the list in the first
case, but not the second. However, I don't want the list to be
collected. The new version seems to fix that issue. Now the control
uses 40MB and when I change it to list' it uses 64MB. Which is more

main :: IO ()
main =
    let list = [1..1000000] :: [Int]
        bin   = encode list
        list' = decode bin :: [Int]
    in do putStrLn (show . length $ takeWhile (< 10000000) list)
          putStrLn (show . length $ takeWhile (< 10000001) list)

More information about the Haskell-Cafe mailing list