Interpreting Linux's free command output

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Interpreting Linux's free command output
# 1  
Old 01-11-2018
Interpreting Linux's free command output

I have two questions on Linux's free command. Below, I have provided output from my home laptop (fedora 26 ) which has 16GB Physical RAM and a production server (RHEL 7.4) which has 24GB RAM.


Question1. What exactly does the buffer/cache column say in free command's output ? buffer/cache is only 1GB in my home laptop but it is 18GB in production server below.


Question2. To know the free RAM available to the system, Can I trust the 'available' column rather than the 'free' column ?
In my home laptop, the 'free' column shows 13GB and available shows 14GB
But, in my production server, when the free command shows just 2GB , the available command shows 9 GB


My Home Laptop with 16 GB RAM (Fedora 26)
Code:
[sysadmin@keithspc ~]$ cat /etc/redhat-release
Fedora release 26 (Twenty Six)
[sysadmin@keithspc ~]$
[sysadmin@keithspc ~]$ uname -a
Linux keithspc 4.12.8-300.fc26.x86_64 #1 SMP Thu Aug 17 15:30:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[sysadmin@keithspc ~]$
[sysadmin@keithspc ~]$ free -h
              total        used        free      shared  buff/cache   available
Mem:            15G        854M         13G        385M        1.0G         14G
Swap:          7.8G          0B        7.8G
[sysadmin@keithspc ~]$
[sysadmin@keithspc ~]$ free -m
              total        used        free      shared  buff/cache   available
Mem:          15939         854       14073         385        1011       14362
Swap:          8034           0        8034
[sysadmin@keithspc ~]$

A production Server (VM) with 24GB RAM (RHEL 7.4)
Code:
[root@manhprod187 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.4 (Maipo)
[root@manhprod187 ~]#
[root@manhprod187 ~]# uname -a
Linux manhprod187 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 13 10:46:25 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@manhprod187 ~]#
[root@manhprod187 ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:            23G        3.3G        2.0G         10G         18G        9.0G
Swap:          2.0G        1.4G        674M
[root@manhprod187 ~]#
[root@manhprod187 ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:          23948        3471        2002       11006       18473        9194
Swap:          2063        1389         674
[root@manhprod187 ~]#

# 2  
Old 01-11-2018
Hi,

Taking your questions in turn:

1. Buffers and cache are essentially types of memory that, whilst they are in use, could be freed up if the system required memory for some other purpose. These are types of memory that are mostly used to hold things which either are yet to be written or have recently been read from disk, in order to accelerate file I/O. So if ever a process genuinely needs more memory than is sitting absolutely unused (which is the total in the 'free' column) more can be obtained by flushing out certain things from the buffers and/or cache.

2. The 'free' column shows you the memory on the system which is genuinely 100% unused - so not in use by a process, and not part of the buffers, cache or shared memory pool. The 'available' column consists of the 'free' memory, plus whatever memory from other categories (mainly the buffers and cache) which could be easily freed up if required. So you can take 'available' as a trustworthy figure as the amount of free memory that applications could use if they needed to.

Hope this helps.
These 2 Users Gave Thanks to drysdalk For This Post:
# 3  
Old 01-11-2018
Thank You drysdalk.

So, when a new process is spawned or an existing process needs extra memory , will the memory be allocated from 'free' (100% unused) memory or memory allocated to Cache+Buffer ?
# 4  
Old 01-11-2018
Hello,

I would imagine that under normal circumstances the kernel would choose to allocate memory from the free pool first, before flushing out buffers, cache or anything else. It all depends precisely on what kind of memory the process is wanting to allocate and for what purpose, but in general memory which is totally unused would be used up first, and then when free memory fell below a certain threshold the system would most likely become more aggressive about freeing up cached memory for actual use by running processes.

In either case, so long as memory is available, a process will be able to use it, so where exactly it comes from is normally not something you need to worry about or consider. If a process needs memory and it's available by one means or another, the system will allocate it.
This User Gave Thanks to drysdalk For This Post:
# 5  
Old 01-11-2018
To be clear, buffers certainly count as "free" memory at need, the kernel is just careful which it uses first.

Your server has much more cache because it's doing much more work. Anything which uses the disk tends to transform free memory into cache, just in case it needs to access that same spot of disk again.
# 6  
Old 01-11-2018
Quote:
Originally Posted by drysdalk
I would imagine that under normal circumstances the kernel would choose to allocate memory from the free pool first, before flushing out buffers, cache or anything else.
In principle: yes. You can change this behavior to some extent by setting kernel tuning parameters but for most purposes the default behavior does quite OK so that this is not necessary. Here, for instance, is a document describing some of the tuning possibilities:

http://docs.gluster.org/en/latest/Administrator%20Guide/Linux%20Kernel%20Tuning/


for a very short introduction what performance tuning is about you might also read this introduction i once wrote.

Before you try that or anything else in this regard: notice that the result can be really catastrophic! Experiment a lot (on a test system, of course), but treat it like open-heart surgery: this can do a dramatic lot of good if you know what you do but it can prove catastrophic results when you don't. Don't be shy, but be careful.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 7  
Old 01-11-2018
Lets say we have two machines with simplified memory status :

10 GB ram, 5 GB buffers & cache, 5 GB free completely.
10 GB ram, 1 GB buffers & cache (lets say you enforce those), 9 GB free completely.

A 64 bit program requests 8 GB of RAM.
How much latency difference is involved in both scenarios when request is made ?

Can someone from kernel programmer perspective say is memory fragmentation issue when dealing with extreme sizes ?
How much time is lost on traversing all those structures, see what to return etc ?

Thank you!

Regards
Peasant.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Concept of free –m command in Linux

I wanted to know the concept of free -m command as there are different rows of Mem, -/+ buffers/cache & Swap in the output. As an example, it is showing 195 as free Mem in my server but 13850 in the free section of the -/+ buffers/cache row. The output needs in depth knowledge of the different... (7 Replies)
Discussion started by: RHCE
7 Replies

2. Shell Programming and Scripting

Linux command to output from a string

Hi All, I have a file with name Is there a LINUX command that will help me to output the word after the 9th Underscore(_). ie the output should be DLY in this case. Can anybody pls help me. Thanks much in advance, Freddie (4 Replies)
Discussion started by: dsfreddie
4 Replies

3. Solaris

Interpreting xntpdc output.

Hi. I wonder what the equal sign in front of the answer means. I have read man pages and googled but found no answer. xntpdc -p =15.5.64.3 15.5.2.51 3 512 377 0.02060 0.057426 0.04965Thanks. Jan (1 Reply)
Discussion started by: vettec3
1 Replies

4. Red Hat

Understand output of "free" command

Hi Friends, I am really confused with the output of "free" command on redhat linux. I can see caching and buffer output on two different areas on the output. Please let me know whats the difference of these two different outputs. Here I am pasting the command output of my server. # free... (3 Replies)
Discussion started by: arumon
3 Replies

5. UNIX for Advanced & Expert Users

Output of Free command in unix?

Hello, I need some help to interpret the below output... What is -/+ buffers/cache? My understanding is, total RAM is 3986152 Bytes, used RAM is 3950904 bytes. What is buffers and cached?? Can any one please interpret this output? It would be great help if some one can help me on this? ... (2 Replies)
Discussion started by: govindts
2 Replies

6. UNIX for Dummies Questions & Answers

Interpreting prtdiag output - 2 or 4 CPUs?

I am having trouble figuring this one out.....Is this a 2CPU or a 4CPU v490 with 16GB? I think it is a 2CPU system, looking for confirmation. $ prtdiag System Configuration: Sun Microsystems sun4u Sun Fire V490 System clock frequency: 150 MHz Memory size: 16384 Megabytes ... (1 Reply)
Discussion started by: config_boy
1 Replies

7. UNIX for Dummies Questions & Answers

interpreting netstat output

hi all, when I run- wcars1j5#netstat -an | grep 8090 127.0.0.1.8090 *.* 0 0 49152 0 LISTEN wcars1j5# 1. does this mean that no one is connected to this port? Regards, akash (1 Reply)
Discussion started by: akash_mahakode
1 Replies

8. Shell Programming and Scripting

Interpreting Logicals/Environment Variables using the read command

Hi All I have something that from the outset seems really trivial but in practice is not quite working. I have the following code sample in my shell script which illustrates the problem echo "enter home directory" read home mkdir $home/newdir The user then enters a logical $HOME... (3 Replies)
Discussion started by: kingpin2502
3 Replies

9. UNIX for Dummies Questions & Answers

Interpreting java output stream as system commands in Solaris

Hi there again, Running Solaris 10 with built-in Java. Seems to compile and run fine. Problem is: Say I want to see contents of current directory. In a shell, I'd just write "ls" and it outputs the content. When I write a Java file, I have the following line: System.out.println("ls"); ... (1 Reply)
Discussion started by: EugeneG
1 Replies

10. UNIX for Dummies Questions & Answers

How to Use the Free Command in Linux

I know that free command displays memory usages however I like to know how the option and the results when I use this command.. PLease respond ASAP thanx... I am a newbie.. :D (1 Reply)
Discussion started by: LiTo
1 Replies
Login or Register to Ask a Question