ghc +RTS -M and -A behaving strange

Hello. When I run a program compiled with ghc-6.12.3 like this: ... +RTS -A2G -M8G -s I get as an answer: Heap exhausted; Current maximum heap size is 0 bytes (0 MB); use `+RTS -M<size>' to increase it. and when I put the options ... +RTS -A2000M -M8000M -s I get Heap exhausted; Current maximum heap size is 4093640704 bytes (3904 MB); use `+RTS -M<size>' to increase it. and both numbers look strange. The behaviour of the program is also strange (instead of "heap exhausted" I'd expect it to do some smore garbage collections, which it does indeed without the -A option)

On Tuesday 28 December 2010 20:37:50, Johannes Waldmann wrote:
Hello.
When I run a program compiled with ghc-6.12.3 like this:
... +RTS -A2G -M8G -s
I get as an answer:
Heap exhausted; Current maximum heap size is 0 bytes (0 MB); use `+RTS -M<size>' to increase it.
Overflow, I'm almost sure. ghci> (8*2^30) `mod` (2^32) 0
and when I put the options
... +RTS -A2000M -M8000M -s
I get
Heap exhausted; Current maximum heap size is 4093640704 bytes (3904 MB); use `+RTS -M<size>' to increase it.
ghci> (8000*2^20) `mod` (2^32) 4093640704 Seems GHC uses Word for the allocation figures and you have a 32-bit system.
and both numbers look strange.
The behaviour of the program is also strange (instead of "heap exhausted" I'd expect it to do some smore garbage collections, which it does indeed without the -A option)

ghci> (8000*2^20) `mod` (2^32) 4093640704
Seems GHC uses Word for the allocation figures
Interesting. Then how can I set the memory bounds that I want? The machine has 12 GB, and if I leave out any RTS options, then the ghc-compiled program will happily consume it all.
and you have a 32-bit system.
uname -a Linux --- 2.6.32-bpo.5-amd64 #1 SMP Sat Sep 18 19:03:14 UTC 2010 x86_64 GNU/Linux cat /proc/cpuinfo processor : 0 .. 7 vendor_id : GenuineIntel cpu family : 6 model : 26 model name : Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz ghc --version The Glorious Glasgow Haskell Compilation System, version 6.12.3

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.
participants (2)
-
Daniel Fischer
-
Johannes Waldmann