kanotix.com

Anything goes - Is there a way to find out how much memory a program takes?

rich.bradshaw - 21.05.2006, 18:16 Uhr
Titel: Is there a way to find out how much memory a program takes?
I am finishing up an introductory course in C and have been writing various little programs. I have found the time function very useful - it tells you how long a program takes to run.

Code:
$ time myprogram


for example, returns the time taken to run the program.

Is there anything similar to find out how much memory the program took up at different times? Ideally i would like to be able to plot a graph of memory vs. time to show how two different approaches to the same prob use different amounts of memory...

Any ideas?

Thanks!
markb - 22.05.2006, 00:25 Uhr
Titel: RE: Is there a way to find out how much memory a program tak
Put a script around the pmap command. Can also script gnuplot to graph it.
rich.bradshaw - 22.05.2006, 08:10 Uhr
Titel: RE: Is there a way to find out how much memory a program tak
Is there anyway to predict what PID a process has before running it? The programs I'm running are very quick to execute, so I don't have time to look up their PID before they close!

Then you can just run

Code:

while(true); do pmap PID | grep total >> memory; sleep 0.1; done

Alle Zeiten sind GMT + 1 Stunde
PNphpBB2 © 2003-2007