how to determine a programs memory usage at runtime?
Bernard James POPE
bjpop at cs.mu.OZ.AU
Mon Jun 21 22:50:30 EDT 2004
On Mon, Jun 21, 2004 at 02:50:39PM +0100, Simon Marlow wrote:
> On 21 June 2004 09:14, John Meacham wrote:
>
> > There might be some RTS calls to query the heap, but someone else is
> > probably more qualified to comment on that.
>
> The value of the mblocks_allocated variable in the RTS will give you the
> number of "megablocks" currently mmap()ed into the address space of the
> executable, which roughly equates to the amount of memory the program is
> using. A megablock is MBLOCK_SIZE bytes, currently 1Mb.
>
> Megablocks are never released, so this only gives you an upper limit for
> the amount of memory in use.
>
Thanks John and Simon,
The mblocks_allocated variable should give me what I want.
I think having access to this would also be useful to people who are
profiling their programs. You see a few papers where people want to report
how much memory their application needs, and having a high-water mark is
usually good enough. Beats trying to get the information from top.
Cheers,
Bernie.
More information about the Glasgow-haskell-users
mailing list