Measuring memory usage of Glasgow Haskell programs

Nicholas Nethercote njn25@cam.ac.uk
Thu, 21 Mar 2002 10:10:49 +0000 (GMT)


Hi,

I'm interested in determining the amount of memory used by various Glasgow
Haskell programs.

The -s runtime option produces information like this:


222,447,136 bytes allocated in the heap
 30,327,124 bytes copied during GC
  4,625,052 bytes maximum residency (12 sample(s))

        847 collections in generation 0 (  0.24s)
         12 collections in generation 1 (  0.19s)

         10 Mb total memory in use

  INIT  time    0.01s  (  0.02s elapsed)
  MUT   time    1.28s  (  1.31s elapsed)
  GC    time    0.43s  (  0.45s elapsed)
  EXIT  time    0.00s  (  0.00s elapsed)
  Total time    1.72s  (  1.78s elapsed)

  %GC time      25.0%  (25.3% elapsed)

  Alloc rate    172,439,640 bytes per MUT second

  Productivity  74.4% of total user, 71.9% of total elapsed


Judging from the source (rts/Stats.c), the "10 Mb total memory in use"
figure here counts the number of megablocks allocated... but what does
this actually mean?

It's fairly straightforward to determine a program's maximum stack size by
fiddling with the -K runtime option and using a binary search.

Is there a similarly easy way to find a program's maximum heap size?  I
don't think fiddling the -M option will work, because that affects the
execution (it can cause extra GCs).

And is there a way to measure static memory usage?  And then the
maximum combination of stack+heap+static?  (I guess that is the "maximum
residency" above)?

Thanks.
--
Nick Nethercote
njn25@cam.ac.uk