31.10.2024, 23:19 UhrDeutsch | English
Hallo Gast [ Registrierung | Anmelden ]

Neues Thema eröffnen   Neue Antwort erstellen
Vorheriges Thema anzeigen Druckerfreundliche Version Einloggen, um private Nachrichten zu lesen Nächstes Thema anzeigen
Autor Nachricht
rich.bradshaw
22 Titel: Is there a way to find out how much memory a program takes?  BeitragVerfasst am: 21.05.2006, 18:16 Uhr



Anmeldung: 14. Jan 2006
Beiträge: 287

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!
 
 Benutzer-Profile anzeigen Private Nachricht senden  
Antworten mit Zitat Nach oben
markb
Titel: RE: Is there a way to find out how much memory a program tak  BeitragVerfasst am: 22.05.2006, 00:25 Uhr



Anmeldung: 09. Aug 2004
Beiträge: 121
Wohnort: Brisbane Australia
Put a script around the pmap command. Can also script gnuplot to graph it.
 
 Benutzer-Profile anzeigen Private Nachricht senden  
Antworten mit Zitat Nach oben
rich.bradshaw
Titel: RE: Is there a way to find out how much memory a program tak  BeitragVerfasst am: 22.05.2006, 08:10 Uhr



Anmeldung: 14. Jan 2006
Beiträge: 287

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
 
 Benutzer-Profile anzeigen Private Nachricht senden  
Antworten mit Zitat Nach oben
Beiträge vom vorherigen Thema anzeigen:     
Gehe zu:  
Alle Zeiten sind GMT + 1 Stunde
Neues Thema eröffnen   Neue Antwort erstellen
Vorheriges Thema anzeigen Druckerfreundliche Version Einloggen, um private Nachrichten zu lesen Nächstes Thema anzeigen
PNphpBB2 © 2003-2007 
 
Deutsch | English
Logos and trademarks are the property of their respective owners, comments are property of their posters, the rest is © 2004 - 2006 by Jörg Schirottke (Kano).
Consult Impressum and Legal Terms for details. Kanotix is Free Software released under the GNU/GPL license.
This CMS is powered by PostNuke, all themes used at this site are released under the GNU/GPL license. designed and hosted by w3you. Our web server is running on Kanotix64-2006.