> [I used n = 9000]
> 
> After some secs it reports:
> 
> Heap exhausted;
> Current maximum heap size is 2998272 bytes;
> use `+RTS -M<size>' to increase it.
> 
> but it eats up 155M(!) of memory (estimated with `top')...

I think I know why this is.  You get some really large integers, which,
because they are represented as arrays, get to be classified as "large
objects" by the GC and placed into immovable blocks of memory.  

Now, there are a couple of places where large objects aren't counted, and
they probably should be:  in the GC check before we do an integer operation
(causing the memory spikes you've seen), and in the code which prints out
the amount of live data for the GC stats.

I'll have a go at fixing this.

Cheers,
        Simon

Reply via email to