Ticket #3110 (closed bug: invalid)

Opened 4 years ago

Last modified 4 years ago

Setting the hard maximum heap size no longer works

Reported by: dons Owned by:
Priority: normal Milestone:
Component: Runtime System Version: 6.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Take this source:

main = do print (product [1..])

Compile it:

$ ghc -O2 A.hs --make -o A -fforce-recomp
[1 of 1] Compiling Main             ( A.hs, A.o )
Linking A ...

Set a small maximum heap size, run the program, then kill it after a few seconds:

$ time ./A +RTS -M1M -sstderr
./A +RTS -M1M -sstderr 
^C      20,177,576 bytes allocated in the heap
          32,352 bytes copied during GC
          18,840 bytes maximum residency (1 sample(s))
          20,888 bytes maximum slop
             682 MB total memory in use (116 MB lost due to fragmentation)

  Generation 0:    38 collections,     0 parallel,  0.00s,  0.02s elapsed
  Generation 1:     1 collections,     0 parallel,  0.00s,  0.00s elapsed

  INIT  time    0.00s  (  0.00s elapsed)
  MUT   time    4.62s  (  5.24s elapsed)
  GC    time    0.00s  (  0.02s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time    4.62s  (  5.26s elapsed)

  %GC time       0.1%  (0.4% elapsed)

  Alloc rate    4,370,879 bytes per MUT second

  Productivity  99.9% of total user, 87.8% of total elapsed


./A +RTS -M1M -sstderr  4.62s user 0.61s system 98% cpu 5.314 total

Far more memory has been allocated in the heap than the 1M max limit.

GHC 6.10.1 on Linux x86_64.

Change History

Changed 4 years ago by dons

  • status changed from new to closed
  • resolution set to invalid

Looks like this might be the GC bug that's already fixed.

Another example:

main = do print (product s)
	  print (sum s)

  where s = [1..]

With GHC 6.10.1

-bash-3.2$ ./A1 +RTS -sstderr -M4M
./A1 +RTS -sstderr -M4M 
      16,307,808 bytes allocated in the heap
       3,982,800 bytes copied during GC
       3,061,660 bytes maximum residency (3 sample(s))
         214,100 bytes maximum slop
            2932 MB total memory in use (1204 MB lost due to fragmentation)

  Generation 0:    29 collections,     0 parallel,  0.02s,  0.03s elapsed
  Generation 1:     3 collections,     0 parallel,  0.02s,  3.06s elapsed

  INIT  time    0.00s  (  0.00s elapsed)
  MUT   time   10.27s  ( 21.53s elapsed)
  GC    time    0.04s  (  3.09s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time   10.31s  ( 24.62s elapsed)

  %GC time       0.4%  (12.5% elapsed)

  Alloc rate    1,587,907 bytes per MUT second

  Productivity  99.6% of total user, 41.7% of total elapsed

It uses too much heap.

With 6.10.2 it is fixed:

-bash-3.2$ ./A1 +RTS -sstderr -M4M
./A1 +RTS -sstderr -M4M 
Heap exhausted;
Current maximum heap size is 3997696 bytes (3 MB);
use `+RTS -M<size>' to increase it.
  28,835,361,100 bytes allocated in the heap
       8,082,024 bytes copied during GC
       3,809,076 bytes maximum residency (5 sample(s))
         385,760 bytes maximum slop
              17 MB total memory in use (11 MB lost due to fragmentation)

  Generation 0: 46743 collections,     0 parallel,  0.21s,  0.26s elapsed
  Generation 1:     5 collections,     0 parallel,  0.03s,  0.04s elapsed

  INIT  time    0.00s  (  0.00s elapsed)
  MUT   time   14.01s  ( 14.10s elapsed)
  GC    time    0.24s  (  0.31s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time   14.25s  ( 14.41s elapsed)

  %GC time       1.7%  (2.1% elapsed)

  Alloc rate    2,058,198,508 bytes per MUT second

  Productivity  98.3% of total user, 97.2% of total elapsed
Note: See TracTickets for help on using tickets.