Complexity bug in garbage collector?

Simon Marlow simonmar at
Fri Jul 22 06:55:47 EDT 2005

On 16 April 2005 23:19, Josef Svenningsson wrote:

> OK, I've cooked up this little program to study the behaviour a
> little closer: \begin{code}
> module Main where
> main = print $ strictId [1..]
> strictId list = let (c,c') = work list c'
>                 in c
>   where work [] y' = (y',[])
> 	work (x:xs) y' = (v,x:v')
> 	  where (v,v') = work xs y'
> \end{code}
> This program just allocates like crazy til it dies. The funny looking
> strictId function is just the strict identity function on lists. (Yes,
> there are simpler ways to achieve the same thing. I just think the
> above function is particularly sweet :-)
> I do the following:
> $ ghc -prof -auto-all --make Main.hs
> $ main.exe +RTS -hd -M<VERY MUCH>
> The resulting graph is suspiciously similar in shape to the one of my
> previous program. The garbage collector is still my primary suspect, I
> simply don't know how to explain the graph otherwise.

I don't see a curve in the profile on my machine:

This was on a Windows box, I also get the same results on a Linux
machine.  I was only able to test with -M600m on the Windows box.  Do
you need more to get the curve?


More information about the Glasgow-haskell-users mailing list