LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 03-04-2008, 08:42 AM   #1
MikeyCarter
Member
 
Registered: Feb 2003
Location: Orangeville
Distribution: Fedora
Posts: 448

Rep: Reputation: 31
Question Identify program memory usage from command line


Me again with memory questions.

I have one or many programs that run periodically which have a high demand for memory.

They start up... through a large portion to swap, then finish up and release their memory. Then the 200K-800K or so is filled up with disk cache, and slowly over the day swaps in the 200K-800K.

I want to identify which programs they are. Is there a command line tool, which I can dump the output to log file, that will report the rough memory usage of a program?
 
Old 03-04-2008, 11:16 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,974
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
top -b -n 1 and a for loop ... for instance to capture
roughly an hour
Code:
for z in `seq 1 3600`; do top -b -d 1 -n 1| awk -f top.awk;sleep 1; done | tee topoutput
where top.awk looks something like this (here it would give you the
top-20 memory hogs per run - see head):
Code:
BEGIN{
  command = "LC_ALL=C sort -k 10,10gr|head -20"
}
{
  line[NR]=$0
  last=NR
} 
END{
  for(i=1;i<8;i++){
    print line[i]
  }
  for(i=8;i<last;i++){
    print line[i]|& command
  }
  close(command, "to")
  while ((command |& getline out) > 0)
    print out
  close(command)
}

Cheers,
Tink
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find max memory usage for process in Linux by command line kashameni Linux - Newbie 9 06-01-2007 01:39 AM
which program will monitor another programs memory usage? zidane_tribal Linux - Software 3 06-17-2006 05:56 PM
Sendmail command line usage Belghouth Debian 1 12-08-2004 10:54 AM
Memory usage of openGL program cjp Programming 3 09-09-2004 06:28 AM
checking memory usage from command line wrepti Linux - General 2 06-16-2004 10:24 PM


All times are GMT -5. The time now is 12:44 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