4

I'm writing a script that is supposed to simply tell me the amount of free physical memory excluding caches and I noticed that my Fedora system shows a different output format than a CentOS system I have a Unix account on:

$ free
              total        used        free      shared  buff/cache   available
Mem:        7865868     3934924      241300      485916     3689644     3093784
Swap:       8388604      950988     7437616
$ ssh -q centos free
             total       used       free     shared    buffers     cached
Mem:       1921876    1848024      73852          0      10120      87124
-/+ buffers/cache:    1750780     171096
Swap:      2097148     240428    1856720
$ free -V                           
free from procps-ng 3.3.10
$ ssh -q centos free -V
procps version 3.2.8

Is there a way I make my Fedora free output look like the CentOS one?

2
  • Does the -o/--old option help? – jofel Jan 21 '15 at 14:48
  • @jofel: it would, but my free doesn't seem to have one. – d33tah Jan 21 '15 at 15:34
6

No, it is not possible.

Note that it is not just a matter of formatting. The free program in procps-ng has been recently updated to include the new MemAvailable metric that was recently introduced in the Linux kernel and that is a much better indication of the memory actually available than the typical (and often wrong) "free + buffers/cache" estimation (see below).

The free program included in procps-ng 3.3.10 does not provide any option to disable this info. And in fact what you are looking at is already the "condensed" format. There is a "wide" option as well (try -w or --wide) which does not aggregate buffers and cache.

If you are writing a script to find out available memory, I would suggest to use the "available" value reported by free, instead of "free + buffers/cache". See this comment on the Linux Kernel mailing list which explains why MemAvailable was introduced:

Many load balancing and workload placing programs check /proc/meminfo to estimate how much free memory is available. They generally do this by adding up "free" and "cached", which was fine ten years ago, but is pretty much guaranteed to be wrong today.

It is wrong because Cached includes memory that is not freeable as page cache, for example shared memory segments, tmpfs, and ramfs, and it does not include reclaimable slab memory, which can take up a large fraction of system memory on mostly idle systems with lots of files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.