Andy's Technotes Home

Linux Memory: the free command

free -m is the command most often used, and here are examples from two different servers

Example 1:
             total       used       free     shared    buffers     cached
Mem:          1880       1816         63          0        156        712
-/+ buffers/cache:        948        932
Swap:         2055          0       2055
Example 2:
             total       used       free     shared    buffers     cached
Mem:          5856       5003        852          0         19       1617
-/+ buffers/cache:       3366       2490
Swap:         2055       1388        667
Example 1 is happily using all its memory, but not swapping out which shows that it isn't needing any more.
Example 2 shows that while it has a hunk free at the moment, it does use a lot more at times when you see how much of its swap space that it has used, perhaps it might need an increase in either RAM or swap space, but we'd have to dig further to figure out what is using the memory.

Lets put in labels and then try to explain them
             total       used       free     shared    buffers     cached
Mem:             A          B          C          D          E          F
-/+ buffers/cache:          G          H
Swap:            I          J          K
  • A - Total RAM seen by Linux, should match what is physically installed or assigned to the VM
  • B - RAM being used by something, but some of it can be release quickly when asked for it
  • C - RAM that isn't doing anything right now. Will be often be low, but don't panic about that. If often zero, and/or rarely over 10% of RAM, then you might have an issue.
  • D - I haven't found documentation on this one yet
  • E - File system buffers. Actively used parts of the file directory structure for quick lookups
  • F - Cached files. Actively/frequently used files that are kept handy for quick access. Can get large on a busy file server, but that is a good thing and something you want to see.
  • G - RAM used by programs and such that can't readily be made available to others
  • H - RAM that is available to other programs when needed. equals C+E+F. Running low here for long is not a good thing.
  • I - Swap drive space, a separate partition on the drive. aka tmpfs
  • J - stuff sitting in memory that wasn't being used lots so it got shoved out of the way when other apps needed more memory than was readily available, though this appears to be a high water mark that doesn't go down after reboots.
  • K - amount of swap space left, running out is the start of bad things, especially if H is low as well.
  • There was an old 'best practice' that indicated that your swap space should be 1 to 2 times your RAM, but that was back in the 32-bit days with much lower RAM sizes than we have now. You don't want to endlessly grow your swap space unless poor performance and wasted electricity is acceptable (spinning harddrives takes more energy, a longer time to do anything than RAM).

    Last updated 2012-06-28 Copyright © 1996-2012 Andy Konecny andyweb @