Recent Changes - Search:
NTLUG

Linux is free.
Life is good.

Linux Training
10am on Meeting Days!

1825 Monetary Lane Suite #104 Carrollton, TX

Do a presentation at NTLUG.

What is the Linux Installation Project?

Real companies using Linux!

Not just for business anymore.

Providing ready to run platforms on Linux

Linux Memory Management

I've been asked this question before and have given answers that never seemed to measure up and just ran across this one and thought we should share it.

The problem is is that ex-MS-Windows-users look at some GUI presentation of memory usage on a Linux system, and in their minds, they try and compare it to what they've previously seen on a MS-system and it's almost like comparing apples to oranges. They think something is broken on the Linux system because it appears that more RAM is being used and especially because they also see that a lot of swap space is being used. I think the post below does a pretty good job of dispelling the "it's-broken-because-it's-different" myth.


Linux machines use swap space as a place to move unused stuff to.
It is also used as work space if real memory is running low.

What a Linux system usually does, is leave as much as possible in memory and uses swap when appropriate / necessary. What is held in RAM is not only the running programs but buffer space for disk read/writes. What will happen over time is that the buffer space that becomes "hotter" [or more current] than some programs (say the webserver is not used all the time) these unused programs are moved to the swap space to free up more memory for more buffers that makes the system run faster.

So if you find that your swap space is full, it is only an indication that the system has moved out non-running programs to long term storage to make way for faster run times... like for caching, for proxy services, or...

jackb@guppy.us c/o trryhend@gmail.com


In most cases the amount of memory in use on a Linux host is used for buffering.

 # free
              total       used       free     shared    buffers     cached
 Mem:       2054400    1571888     482512          0     206596     961564
 -/+ buffers/cache:     403728    1650672
 Swap:      2104464       2460    2102004

So, in this case, we see that there is actually 1650672 bytes free if you eliminate that used by buffers/cache. But at first somone might think that only 482512 is free.

With regards to memory utilization and swapping, this can be somewhat controlled with the vm.swappiness parm:

 # sysctl vm.swappiness
 vm.swappiness = 60

SUSE sets a pretty high (60) swappiness value. That means that it is more likely to swap things out that aren't being used. This can have performance implications with regards to some programs that occupy or use a lot of memory. Some people like a lower swappiness value, so that the larger programs (especially) will tend to stay in memory. Others believe that high swappiness values (even 100) are better to keep the memory free (not sure of the logic of that... but at least one kernel developer feels strongly that way).

Chris Cox June 15, 2006, at 12:47 AM

Page last modified on June 21, 2006, at 05:59 AM