LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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-09-2009, 11:59 AM   #1
pablopla
LQ Newbie
 
Registered: Dec 2008
Posts: 6

Rep: Reputation: 0
understanding memory usage


Hi,

I'm using 'free' to see memory usage on my ubuntu server 8.10.
Can you please explain the difference between Mem and buffers/cache?
I expect low memory usage but there is almost no free Mem. On the other hand there is a lot of free buffers/cache.

total used free shared
Mem: 1747764 1601008 146756 0
-/+ buffers/cache: 91864 1655900
Swap: 917496 496 917000

Thanks
 
Old 01-09-2009, 12:14 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 271Reputation: 271Reputation: 271
The line
Code:
-/+ buffers/cache: 91864 1655900
is actually the line that matters since it doesn't count the buffer/cache memory. It shows you have 91MB used by applications and 1.6 GB free for application usage. The top line shows all the memory used, but it includes buffers and caches.
 
Old 01-09-2009, 12:40 PM   #3
pablopla
LQ Newbie
 
Registered: Dec 2008
Posts: 6

Original Poster
Rep: Reputation: 0
what does it means that 1655900 is used by buffer/cache?
is it normal?
Will ubuntu automatically decrease the cache if another application needs the memory?

Can you please explain what are VIRT, RES and SHR when running 'top'?

Thanks
 
Old 01-09-2009, 01:19 PM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181
Roughly (because I've never found anything that explains these statistics precisely):

Quote:
Originally Posted by pablopla View Post
what does it means that 1655900 is used by buffer/cache?
When an application does ordinary file I/O or it maps files into its address space (which is the usual way of accessing most executable code) the OS may buffer or cache parts of the file in memory to reduce disk I/O.

Quote:
is it normal?
Yes. Unless you have absurdly more ram than your system has use for, most of the memory that isn't in use directly by applications should be in use by buffer/cache.

Quote:
Will ubuntu automatically decrease the cache if another application needs the memory?
Usually. The OS must make a rather complex decision when memory is needed. If the most recent use (only measured approximately) of some buffer/cache memory was less recent than the most recent use of all application memory, then the OS certainly should free some buffer/cache when an application needs memory. That is the typical result in a system with more ram than it really needs. But if some application memory was less recently accessed than any buffer/cache memory, the OS design must balance the probability of reuse being lower for less recently used against it being lower for buffer/cache than for application and it may decide to swap out some application memory rather than free some buffer/cache memory.

Quote:
Can you please explain what are VIRT, RES and SHR when running 'top'?
VIRT is the total virtual memory size of the process. It is often misleadingly high because it includes things like demand zero memory, and unaccessed portions of mapped files.

RES is the amount of the process's memory currently physically mapped to actual ram. It might be misleadingly low because I think it excludes pages that could be soft faulted. In obscure cases it could be misleadingly high because pages might be double mapped (I think they would be double counted). In more common cases it will be misleadingly high because of shared (with other processes) mappings. But it is a fairly good measure of the physical ram footprint of a process.

SHR is the amount of a process's virtual memory that is mapped in a way that it could be shared, for example the parts into which unmodified sections of .so files are loaded. But nothing tells you how much of that is actually shared nor how much of it is actually in physical memory.
 
Old 01-09-2009, 01:59 PM   #5
pablopla
LQ Newbie
 
Registered: Dec 2008
Posts: 6

Original Poster
Rep: Reputation: 0
thanks.
 
  


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
Understanding memory usage on Linux mlsx LQ Articles Discussion 9 03-07-2011 04:36 AM
X hangs after prolonged usage ... memory usage goes upto 195MB duryodhan Slackware 18 05-10-2007 07:16 PM
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 09: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 05:45 AM


All times are GMT -5. The time now is 10:20 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration