Agressive memory caching

Hakan Koseoglu hakan at koseoglu.org
Fri May 7 18:43:19 UTC 2010


Hi Mike,
On 7 May 2010 19:11, Mike A. Leonetti <mleonetti at evolutionce.com> wrote:
>>> I have two different Ubuntu virtual servers (the guests) both running in
>>> VMWare.  One of the servers is caching over 1.5 GB of memory filling up
>>> the rest of the RAM.  The other server is not doing this.  Is this
>>> really mainly only depedant on the applications running that the memory
>>> is being cached so high?  VMWare keeps complaining that the Guest is
>>> running out of memory.  I'm assuming this really isn't the case.
>> Could this be a program with a memory leak?
> HTOP still shows that the cached memory is "free".  Just that it's
> cached.  Would a memory leak cause this?
A memory leak would show up as an application consuming more and more
memory, not free.

The "cached" memory is any unusued memory by the applications and as a
result used as a cache by the system. This memory will be presented
back to the application when/if one of them requests. Any used memory
segment not accessed for a while will be swapped out, even if you have
a lot of free memory. This particular behaviour can be tuned by the
swappines kernel parameter (here's an excellent article regarding that
parameter http://lwn.net/Articles/83588/).

My little laptop here has the following:
hakan at photon:~$ free
                    total       used           free     shared
buffers      cached
Mem:       3341004    2505960     835044          0     338488    1100668
-/+ buffers/cache:    1066804    2274200
Swap:      8000328          0    8000328

So out of 3.2GB of RAM I have, 2.5GB is used by various applications,
820MB+ is not used at all and approx 1GB is used by the file system
cache to speed things up. As I access more and more disk data, the
amount of free memory will drop down to a couple of MBs and this will
have no harm as long as I don't start swapping significantly.

If your cached memory increases quite quickly after a restart, this
probably means that you have an application that does plenty of I/O
and free memory has been used for caching this data to speed up the
things.

My little web/samba server here is busy reading and and writing hence
I have only 23MB left free and almost all of the memory used by the
file system cache, as it should be and a tiny bit has been swapped
out:

hakan at jupiter:~$ free
                    total       used       free          shared
buffers     cached
Mem:       1997920    1974000      23920          0      40960    1661440
-/+ buffers/cache:     271600    1726320
Swap:      3229024        344    3228680

-- 
Hakan (m1fcj) - http://www.hititgunesi.org




More information about the ubuntu-users mailing list