LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-19-2008, 10:06 AM   #1
pudhiyavan
Member
 
Registered: Oct 2003
Location: Linux world
Distribution: redhat,mandy,centos,debian,ubuntu
Posts: 209

Rep: Reputation: 30
memory usage few clarifications


hi when i used top and atop and reading the /proc/meminfo gave me some kind of doubts

atop results follows
MEM | tot 2.0G | free 376.3M | cache 558.6M | buff 57.4M | slab 54.4M

/proc/meminfo
MemTotal: 2056040 kB
MemFree: 386156 kB
Buffers: 58720 kB
Cached: 571980 kB


my question is when the total memory is 2 GB and as per atop and meminfo results it shows around 620mb of usage, what happend to rest of the memory
and free memory is only 380mb

where in
top shows like this
Mem: 2056040k total, 1613036k used, 443004k free, 58744k buffers


the last one is htop, it show only 620mb of used memory and rest are all free. but the problem here is i cannot utilise the live monitor from htop.

can any one suggest me how can i monitor the realtime memory usage in command line?
 
Old 06-19-2008, 01:13 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
There is not an easy answer to your question. Unix/Linux systems manage memory very efficiently. They also attempt to use as much memory as you've paid for (memory unused is wasted money). When data is read from disk, it is stored in memory buffers. And it remains in buffers even when no longer currently in use, in the event it might be needed again soon. If not, it is purged and the memory returned to the free pool.

Each utility has its own method for showing how memory is being used; they are all generally gross-level measurements at best. Memory is used in a variety of ways, and there is no simple equation such as a+b+c = total ram.

What is it that you are trying to accomplish by monitoring real time memory usage?
 
Old 06-19-2008, 01:41 PM   #3
pudhiyavan
Member
 
Registered: Oct 2003
Location: Linux world
Distribution: redhat,mandy,centos,debian,ubuntu
Posts: 209

Original Poster
Rep: Reputation: 30
Thanks for the reply mr.c
according to my audit req. i have to update average cpu/memory utilization info in a provided document everyday. but recent days the top command shows the mem utilization to 90% which no one will accept that much of utilization. so friend of mine recommended htop to have realtime figure, i tried it and its pretty good to see only 18% of mem is in use, rest are all free.

can you pls help me to have clear picture of how much total memory is being utilised, if possible is there a way we can store the htop results into some format of text file?
 
Old 06-19-2008, 02:05 PM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Unix/Linux systems consume *all* memory almost all of the time. That is normal, expected, and optimal.

I'm afraid you'll have to learn a bit more about how memory is used in these systems. For starters, perhaps look at:

http://mail.nl.linux.org/linux-mm/2003-03/msg00077.html
 
Old 06-24-2008, 12:34 AM   #5
pudhiyavan
Member
 
Registered: Oct 2003
Location: Linux world
Distribution: redhat,mandy,centos,debian,ubuntu
Posts: 209

Original Poster
Rep: Reputation: 30
Sorry for the delayed reply mr.c. nice article you had recommended. will start monitoring as mentioned in the document then will get back to this topic..
 
Old 06-24-2008, 12:59 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Simple is best - try this
Code:
free -m | awk '{if (NR == 2) tot = $2; else if (NR == 3) used = $3} END{print "Memory usage: " used " of " tot " Megabytes}'

Last edited by syg00; 06-24-2008 at 01:44 AM. Reason: Added total field
 
Old 06-24-2008, 02:52 AM   #7
pudhiyavan
Member
 
Registered: Oct 2003
Location: Linux world
Distribution: redhat,mandy,centos,debian,ubuntu
Posts: 209

Original Poster
Rep: Reputation: 30
thanks syg00

i tried it it shows me only 649 mb of usage...

[root@web ~]# free -m | awk '{if (NR == 2) tot = $2; else if (NR == 3) used = $3} END{print "Memory usage: "used" of "tot" Megabytes"}'
Memory usage: 649 of 3943 Megabytes

free
total used free shared buffers cached
Mem: 4037892 4007056 30836 0 283296 3058836
-/+ buffers/cache: 664924 3372968
Swap: 3903784 0 3903784

in the first line it shows used is 4007056, are these buffers/cache not important to mention?

Last edited by pudhiyavan; 06-24-2008 at 03:18 AM.
 
Old 06-24-2008, 04:47 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
They are important, but don't represent storage allocated (directly) by the applications you are running. When those applications need more memory, buffers and cache will be released to accommodate.
Have a read of this.
 
Old 06-25-2008, 08:48 AM   #9
pudhiyavan
Member
 
Registered: Oct 2003
Location: Linux world
Distribution: redhat,mandy,centos,debian,ubuntu
Posts: 209

Original Poster
Rep: Reputation: 30
very cute, good article dear. thanks for this info..
 
Old 06-25-2008, 11:50 AM   #10
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Shared memory is also storage allocated directly by programs - but it happens to be sharable, so several cooperating apps will use the shared space.
 
  


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
X hangs after prolonged usage ... memory usage goes upto 195MB duryodhan Slackware 18 05-10-2007 06:16 PM
Memory Usage Spaw Usage Swappiness Issues joelunch Linux - Software 3 01-04-2006 06:16 PM
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 08:43 PM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM
Controlling CPU usage & memory usage Saravana babu Linux - Software 0 02-18-2004 05:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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