Determining free memory on Linux

When checking the amount of free memory on a Linux server, it’s easy to think you’re running out of memory when you’re not.

For example, here’s the output of free -m on a server with 4GB of RAM:

With a quick glance, you might start sweating. Only 39 MB of free memory? Put down the antacid – you’ve got a lot more free memory than you think.

Memory Caching & Buffers

Reading data from a disk is far slower than accessing data from memory. Linux caches blocks from the disk in memory. In fact, Linux uses all free RAM for the buffer cache to make reading data as efficient as possible.

What happens if a program needs more memory than what’s available? The buffer cache will shrink to accommodate the increased memory needs. The buffer cache works like your most efficient coworker: when things aren’t busy, he runs around making things run smoother. When an important task comes up, he drops the less important chores.

Actual Free Memory

The actual free memory available is:


Actual Free Memory = Free (39 MB) + Buffers (95) + Cached (3590) = 3,724 MB

That’s 95x more free memory than than we initially thought.

If you are using Scout, Eric Lindvall’s Memory Profiler plugin already takes the buffer cache into account when determining free memory. This plugin is installed by default on newly monitored servers.

Also See: