Determining the memory usage of a program

Peter Barker pbarker at barker.dropbear.id.au
Tue Feb 12 21:37:09 EST 2002


On Tue, 12 Feb 2002, Simon Burton wrote:

> >>I have a program which takes quite a while to run, and eventually dies --
> >>I think because it runs out of memory. I would like a command where I can
> > Have I mentioned strace before? :-)
> what has it to do with memory usage?

It will show you the mallocs etc. But that's not why I mentioned it. I
mentioned it because strace may show you when a memory allocation fails -
if something hands you back an -ENOMEM, then Michael's guess was almost
certainly correct.

> > Have you had a squiz at the man page for time?? :-)
> I did. it measures time. is yours different?

Somewhat.
       time - time a simple command or give resource usage

Resource being the critical bit. A few of the more choice options for the 
format string you can supply:
       %M     Maximum resident set size of the process during its
              lifetime, in Kbytes.
       %t     (Not  in  tcsh.)  Average  resident set size of the
              process, in Kbytes.
       %K     Average total (data+stack+text) memory use  of  the
              process, in Kbytes.

I didn't realise just how nifty time(1) was until I saw that page!

> \bye

! Undefined control sequence.

Yours,
-- 
Peter Barker                          |   N    _--_|\ /---- Barham, Vic 
Programmer,Sysadmin,Geek              | W + E /     /\                
pbarker at barker.dropbear.id.au         |   S   \_,--?_*<-- Canberra      
You need a bigger hammer.             |             v    [35S, 149E]   
qq%I've never heard of it or used it, apart from finding it in the Camel
 book and saying "Oh god".% -- Onceler







More information about the linux mailing list