Haskell API for memory useage

Donald Bruce Stewart dons at cse.unsw.edu.au
Sat Mar 10 09:00:33 EST 2007

> Hi,
> Haskell has getCPUTime to get the amount of CPU Time that has been
> consumed, but has no equivalent for memory use. I would like to get
> something similar to -RTS -t, but from a Haskell program. I'm not
> overly fussed about what memory statistic I get, as long as it is
> something that corresponds in some way to the amount of memory that
> has been used - cells, heap size, live heap etc are all fine.
> So, I'm after something like: getMemoryUse :: IO Integer
> Is there anything I can use to do this?

This stuff is surprisingly tricky for some reason. Have a look at the
gtop (C?) lib (there's also a perl binding used for the shootout). 

I'm not sure why shells in general don't provide a 'memory' combinator,
considering we have 'time'.

-- Don

More information about the Glasgow-haskell-users mailing list