LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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: 492

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: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:43 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration