Is Linux really out of memory?

If you have ever looked at RAM usage on a Linux server you might have noticed that the server might be running out of memory. This is misleading. Let’s take the following example:

[somedude@ultra ~]$ free
             total       used       free     shared    buffers     cached
Mem:      16432988   16378844      54144          0     647204   14692400
-/+ buffers/cache:    1039240   15393748
Swap:     16383992    4501164   11882828

At glance it looks like you have 54144 bytes of memory free. This is not true. This number specifies that 54144 bytes are not used for anything. To get amount of memory that is free for use by programs, you need to look at the number below 54144. In this case 15393748 bytes is available memory for use by programs.

In Linux, unused memory is used for disk caching to speed things up. In the above example, when system attempts to load program into memory, chunk of disk cache is freed up so program can load.

So, in the above, the system has in reality 93% of memory available for programs.

Sometimes this might be a little confusing for newcomers.