LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 01-04-2010, 09:02 PM   #1
trist007
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 972

Rep: Reputation: 56
how to check ram usage in linux...


I am running Slackware 13.0. I am aware of free -m, vmstat, top, etc. However, none of these programs display how much ram each program is using. Is there a program that displays how much ram each program is using? I run a headless so I'd need a program that runs in CLI.

I know that top command shows %MEM (only two programs were using 0.1%MEM) but after running free -m I only have a total of 400 MB ram left out of my 1.5 GB of ram. Where is all that lost ram?

Last edited by trist007; 01-04-2010 at 09:05 PM.
 
Old 01-04-2010, 09:12 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,950
Blog Entries: 11

Rep: Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860
Why don't you post the output of e.g. top here in code tags?
 
Old 01-04-2010, 09:18 PM   #3
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
free -m shows memory:

total used free shared buffers cached

So what is your question?
 
Old 01-04-2010, 09:19 PM   #4
evo2
Senior Member
 
Registered: Jan 2009
Location: Japan
Distribution: Debian
Posts: 4,821

Rep: Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022
By default top sorts by cpu usage. If you have not tried already it may be useful to get top to sort by memory usage.

Inside top, type "<Shift>-f" then type "n", then type "<Enter>".

Cheers,

Evo2.
 
Old 01-04-2010, 11:02 PM   #5
trist007
Member
 
Registered: May 2008
Distribution: Slackware
Posts: 972

Original Poster
Rep: Reputation: 56
Ah yes, top did it, thanks Evo. VIRT is the ram in KB correct?

I am trying to get how much KB of RAM each program is using, not necessarily percentage, which could be calculated but I want convenience hehe.

Last edited by trist007; 01-04-2010 at 11:07 PM.
 
Old 01-04-2010, 11:06 PM   #6
evo2
Senior Member
 
Registered: Jan 2009
Location: Japan
Distribution: Debian
Posts: 4,821

Rep: Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022Reputation: 1022
Quote:
Originally Posted by trist007 View Post
Ah yes, top did it, thanks Evo. VIRT is the ram in KB correct?
From the man page:
Code:
      o: VIRT  --  Virtual Image (kb)
          The total amount of virtual memory used by the task.  It includes all code, data and shared libraries plus pages that have been swapped out.

          VIRT = SWAP + RES.
so yes it seems so.

Cheers,

Evo2.
 
Old 01-05-2010, 12:06 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,799

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
Probably of more interest might be RSS. For this sort of thing I find it easiest to run through /proc/*/stat and pull out what I want with awk.
Code:
echo -e "RSS\t\tName\n---\t\t----" ; for i in /proc/*/stat ; do awk '{print $24" \t:\t" $2}' $i 2>/dev/null ; done | sort -nr | head -n 10
 
Old 01-05-2010, 12:18 AM   #8
Hendronicus
Member
 
Registered: Feb 2006
Location: Oldsmar, Fl. USA
Distribution: Slackware, Ubuntu
Posts: 173

Rep: Reputation: 38
There is a program called htop that might do what you want. If you run it as super-user it can do quite a bit of task management as well.

Last edited by Hendronicus; 01-05-2010 at 12:18 AM. Reason: clarity
 
Old 01-05-2010, 12:39 AM   #9
Hendronicus
Member
 
Registered: Feb 2006
Location: Oldsmar, Fl. USA
Distribution: Slackware, Ubuntu
Posts: 173

Rep: Reputation: 38
Quote:
Originally Posted by trist007 View Post
I am running Slackware 13.0. I am aware of free -m, vmstat, top, etc. However, none of these programs display how much ram each program is using. Is there a program that displays how much ram each program is using? I run a headless so I'd need a program that runs in CLI.

I know that top command shows %MEM (only two programs were using 0.1%MEM) but after running free -m I only have a total of 400 MB ram left out of my 1.5 GB of ram. Where is all that lost ram?
I just re-read your question and I would venture to guess that your "lost" RAM is actually cache + shared libs. Linux, by default, caches every single disk access up to available RAM and then releases it back if programs need it. There are ways to turn off this behavior but you probably don't want to.
 
Old 01-05-2010, 08:29 AM   #10
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,570

Rep: Reputation: 510Reputation: 510Reputation: 510Reputation: 510Reputation: 510Reputation: 510
http://www.linuxatemyram.com/
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nagios - check RAM usage on remote server mikeshn Linux - Software 9 08-04-2011 02:44 AM
Optimise linux for maximum RAM usage? jmite Linux - Newbie 1 07-10-2009 03:31 AM
How to check the memory usage in an embedded Linux system? alanchansl Linux - Embedded & Single-board computer 7 07-24-2008 09:21 AM
how to check ram usage by process christopher_c Linux - Newbie 3 04-30-2008 02:58 PM
Linux RAM usage paulsiu Linux - Hardware 1 10-25-2006 08:10 PM


All times are GMT -5. The time now is 08:44 AM.

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