LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-22-2009, 06:43 PM   #1
youwin
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Rep: Reputation: 0
view memory of a quick running program


Is there a way to find out what the maximum amount of memory a program uses in its short run time?

I'm not sure how I can access /proc/pid/stat when its gone so soon after i begin running the program.

I thought I might try to parse the output of an strace, but i havent been able to determine what is the memory usage of the stack with that, only changes with sbrks and mmap2s none of which look like they come from changes on the stack (forgive my ignorance). This might be useful still yet incomplete and probably the wrong way to do it.

It would be good to find what the maximum memory usage is, or better yet, to find what the memory usage is at each time it increases, in a good format to search through it.
 
Old 02-23-2009, 09:34 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 226

Rep: Reputation: 43
Try:
Code:
top -i -d 0.01 -b | grep foo > foo.data
top is very configurable. You can change the fields that are displayed if the default is not what you need. Check the man page.
 
Old 02-26-2009, 07:13 PM   #3
youwin
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Original Poster
Rep: Reputation: 0
the problem with using top is that it isnt giving memory for the specific process i need right from the get go. as soon as i start the program whose memory i want to measure, its done.
 
Old 02-26-2009, 08:38 PM   #4
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 226

Rep: Reputation: 43
You need to start the top command I posted in a terminal first and then in another terminal start your program. Then kill the top process (ctrl-c) and look in the file you directed the output to.

From the top man page:
Quote:
-b : Batch mode operation
Starts top in ’Batch mode’, which could be useful for sending output from top to other programs or to a file.
In this mode, top will not accept input and runs until the iterations limit you’ve set with the ’-n’ com‐
mand-line option or until killed.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Program to view the contents of memory at a particular address kushalkoolwal Linux - Software 2 06-04-2008 06:05 PM
Gnome System Tray Show Program Running in Memory help nedson Linux - Newbie 1 04-20-2006 08:21 PM
quick q: KDE + KDM: automatically running a program after login atom Linux - Software 2 04-12-2005 08:50 AM
A quick q: how to view chmod stuff? orange400 Linux - General 2 04-23-2004 05:44 AM
Memory Leak when using memory debugging C program on SuSE SLES8 babalina Linux - Distributions 0 10-06-2003 09:39 AM


All times are GMT -5. The time now is 08:50 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration