LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   understanding memory usage (https://www.linuxquestions.org/questions/linux-newbie-8/understanding-memory-usage-696112/)

pablopla 01-09-2009 10:59 AM

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

pljvaldez 01-09-2009 11:14 AM

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.

pablopla 01-09-2009 11:40 AM

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

johnsfine 01-09-2009 12:19 PM

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

Quote:

Originally Posted by pablopla (Post 3402556)
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.

pablopla 01-09-2009 12:59 PM

thanks.


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