RE: Measuring memory usage of Glasgow Haskell programs

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).
You can find an approximation to the maximum instantaneous resident data size by switching to 2-space collection (+RTS -G1) and fixing the allocation area size to some arbitrarily small value (eg. +RTS -A256k). The program will take a long time to run, because it will do a major GC every time the allocation area is full up. You can decrease the run time (and the accuracy) by increasing the size of the allocation area. The stats output will then tell you both the maximum and average residency of the program.
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)?
The residency only takes into account heap-resident data, static data isn't included. I think the stack is excluded from this figure, though. Cheers, Simon
participants (1)
-
Simon Marlow