[Haskell-cafe] ghc +RTS -M and -A behaving strange

Daniel Fischer daniel.is.fischer at googlemail.com
Wed Dec 29 20:39:28 CET 2010


On Wednesday 29 December 2010 15:41:22, Johannes Waldmann wrote:
> > ghci> (8000*2^20) `mod` (2^32)
> > 4093640704
> >
> > Seems GHC uses Word for the allocation figures

Looking at the rts-code, maxHeapSize is in blocks (4096 bytes, as far as I 
can see) and the code for setting it uses double and StgWord64.
Though the type of maxHeapSize is nat (unsigned int, which may be 32 bits 
even on 64-bit systems?), 8G are 2097152 blocks, so the number is well 
within range and no overflow should occur.

But the `heap exhausted' message gives the heap size in bytes, with 
argument type lnat (unsigned long).

So if sizeof(unsigned long) is 4 on your system, the heap exhausted message 
would print 0 bytes resp 4093640704 bytes even if the heap size is 
correctly set to 8G resp 8000M.

Can you watch the allocation with top to see whether the programme consumes 
the 8G and just the reported figures are wrong?

In any case, some bug report is in order, it only remains to find out 
whether just the reporting is off or also the allocation code.

>
> Interesting. Then how can I set the memory bounds that I want?

Should work, as far as I can tell.

> The machine has 12 GB, and if I leave out any RTS options,
> then the ghc-compiled program will happily consume it all.
>
>




More information about the Haskell-Cafe mailing list