[Haskell-cafe] Re: Space Leak Help

2007-02-04 Thread Dominic Steinitz
If anyone wants to play with this, here's a version of the leak that doesn't need any libraries or extensions. pad causes a stack overflow and pad1 uses up about 6m of heap. Dominic. module Main(main) where import Data.Word import Data.Bits import Data.List pad = pad' 0 where pad' l [] =

Re: [Haskell-cafe] Re: Space Leak Help

2007-02-04 Thread Claus Reinke
pad causes a stack overflow and pad1 uses up about 6m of heap. pad1 xs = xs ++ [0x80] ++ ps where l = length xs pl = (64-(l+9)) `mod` 64 ps = replicate pl 0x00 wild guess: if you compute the length when the consumer reaches ps, you hold on to a copy of xs longer than needed,

Re: [Haskell-cafe] Re: Space Leak Help

2007-02-04 Thread Anatoly Zaretsky
On 2/4/07, Dominic Steinitz [EMAIL PROTECTED] wrote: pad causes a stack overflow and pad1 uses up about 6m of heap. pad = pad' 0 where pad' l [] = [0x80] ++ ps where pl = (64-(l+9)) `mod` 64 ps = replicate pl 0x00 pad' l (x:xs) = x : pad' (l+1) xs pad =