The wikis are now using the new authentication system.
If you did not migrate your account yet, visit

SDB:Low amount of free memory

Şuraya atla: kullan, ara


The amount of free memory reported by the free command is low; for example:

             total       used       free     shared    buffers     cached
Mem:       8092856    7136972     955884          0     124452    6642888
-/+ buffers/cache:     369632    7723224
Swap:      3020212          0    3020212

and you suspect this may cause problems when the system is put under additional load.

Background: memory hierarchy

Computer memory that functions at speeds close to a modern processors is very expensive. For economic reasons, in modern computing a memory hierarchy is used which ranges from very fast, but small memory (like cache chips) via slower but larger memory (like RAM chips) to much slower, but very large memory (like hard disks).

For these same economic reasons, it is important to try to keep data that the processor needs frequently (i.e. data that's part of the current system workload) "close to the processor", i.e. in as fast a form of memory as is possible. When the demand for memory increases and the system's RAM gets full,data that hasn't been used for a while can be moved to disk and retrieved back from there when needed. This is known as swapping. A low amount of swapping is acceptable for most uses, but when the system starts swapping a lot it slows down significantly and you should consider adding more RAM to it to restore performance.

Linux' use of RAM

Linux tries to use a system's RAM in a way that makes the most economical sense: when the processes running on the system don't need all the RAM, Linux puts the remaining RAM to use by holding copies of frequently and recently accessed files for faster access in it (so-called I/O cache and buffers); of course, changes are also safely written to disk.

In the example free output above, the system has 8 GB RAM; the running processes use less than 2 GB RAM, so the kernel has started to use most of the remaining memory (over 6 GB) as cache/buffer. Thus, this system's situation is quite fine and in fact the system isn't using swap space at all.

For a different example, consider this free -m output ("-m" to use megabytes as the unit):

             total       used       free     shared    buffers     cached
Mem:          2016       1963         53          0        143        490
-/+ buffers/cache:       1328        688
Swap:         2055        449       1605

On this system, the (relative) demand for memory is higher than in the earlier example: almost no RAM is really free and the amount in use for buffers and cache is smaller as well. The system has swapped out some data. Using vmstat one can see that the system is not swapping heavily currently:

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
 2  0 460592  55012 147012 502596    1    2    16    15    5     9 13 20 66  2

(in fact, it's close to not swapping at all) so its performance is still quite acceptable. If additional memory load was put on this system, the buffers and cache would go down and in the end the free RAM would get close to zero and the system would start to do significant swapping.

Related tools

Aside from free and vmstat which are included in the base system's procps package, the tools in the sysstat package can be used to keep logs of the system's load over time. For instance, the sar command lists the percentage of time the CPU is waiting for I/O; on a system that's starting to swap, this percentage will go up.

The behaviour of the virtual memory subsystem of the Linux kernel (which is responsible for swapping) can be tuned through the /proc filesystem (see /proc/sys/vm/). This subject is beyond the scope of this article though.


Linux tries to make economically sensible use of a system's RAM. When the amount of free RAM as reported by free becomes low, this is not always a problem. Only when the "buffers" and "cached" values go down and the "swap used" value goes up, the system is really running out of RAM and adding more RAM to it should be considered.

Aside from free and vmstat, the tools in the sysstat package can be used to evaluate a system's memory load over time. <keyword>free,memory,RAM,lowmemory,swap,buffers,cache</keyword>