LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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
  Search this Thread
Old 01-04-2010, 09:02 PM   #1
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

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

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
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
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Original Poster
Rep: Reputation: 70
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
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,726

Rep: Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706Reputation: 1706
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: 21,361

Rep: Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190Reputation: 4190
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: 176

Rep: Reputation: 50
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: 176

Rep: Reputation: 50
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,824

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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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