This is the blog for Scout, Enterprise-grade server monitoring without the bloat.
70+ plugins, realtime charts, alerts, and Chef/Puppet-friendly configuration.

Free memory on Linux: free -m vs /proc/meminfo

Posted in HowTo | Comments Comments

How much memory is really available on your Linux box? Don't use /proc/meminfo to find out, use free -m instead. You may have more memory available than you thought.

Here's an example. /proc/meminfo says about 330MB is free:

    ~ $cat /proc/meminfo 
    MemFree:        340996 kB
    ..

free -m gives the following:

    ~ $free -m
                             total       used       free     shared    buffers     cached
    Mem:          1024        691        332          0         86        288
    -/+ buffers/cache:        316        708
    Swap:         2047         68       1979

You'll see the "buffers" and "cached" columns, which tell you about the amount of memory that the kernel is using for filesystem buffers, etc.

This sort of cached data will be freed by the kernel when an application tries to allocate more than what is "free", which is why the "-/+ buffers/cache" line is really the important line to pay attention to when you're checking out the free memory on a system.

So in this example, 708MB is how much memory is technically available for allocation should an application need it. The "buffers" (86MB) and "cached" (288MB) will be released by the kernal if they are needed.

All credit for this post goes to Eric Lindvall, who also wrote the memory profiler plugin.

Subscribe to our RSS feed or follow us on Twitter for more insights on Linux performance.

Comments

comments powered by Disqus