Quantcast
Channel: GoLinuxHub
Viewing all articles
Browse latest Browse all 392

What is buffers/cache in free command in Linux ?

$
0
0
When we run free command to view the memory usage in Linux we get a similar output as below
# free -m
             total       used       free     shared    buffers     cached
Mem:          1869       1398        471          0         24        400
-/+ buffers/cache:        974        895
Swap:         3999          0       3999

Now here most of the terms should be understood but ever wondered what is that buffers/cache ?

Let me explain all the parameter used here

total: It shows you the total memory assigned to your machine but again the value shown to you is not the real value as it excludes a small amount of RAM which is reserved for kernel as in my case my machine has 2048 MB but out of which it only shows me 1896 MB where 152MB is reserved by kernel for booting purpose

used: The total used memory by the processes in your OS

free: Memory not in use
total (1869) = used (1398) + free (471)
Now coming to -/+ buffers/cache

First value i.e 974 in my case gives the original value of used minus the sum buffers + cached 
( 1398 - (400 + 24) ) = 974
Second value i.e. 895 gives the original value for free plus the sum buffers + cached 
( 471 + 24 + 400 = 895 ) = 895
Again the last section shows you the total assigned, used and free swap memory having no much of any mathematical calculation.

How do you understand if your system is low on memory?

This question can be a bit complicated to answer unless you understand the difference between Virtual memory, used memory and buffers/cache.
Most of the time you observe the output of free command, free memory section will be low value but comparatively buffers+cache value would be higher. Now this is not a bad thing actually since your OS has reserved this memory to speed up your most used process by keeping them in the cache. But in case any new process is executed and your system is low on memory then these cache would be automatically released to make space for memory reservation of new processes.

How to free cache memory?

You can do this using the below command
# echo 3 > /proc/sys/vm/drop_caches
These are the different values which you can use with the above command
echo 1 is clearing only page cache
echo 2 is to clear free dentries and inodes
echo 3 is clearing page cache, dentries and inodes


Related Articles:
How to clear cache memory in Linux
How to increase Swap memory size in Linux
What is virtual memory, paging and swap space?
What is swappiness and how do we change its value?


Follow the below links for more tutorials

How to keep a process running after putty or terminal is closed
How to change the MAC Address of Ethernet device in Linux?
Step by Step CentOS 7 (64 bit) Installation Guide with Screenshots
What is nice and how to change the priority of any process in Linux?
How to use yum locally without internet connection using cache?
What is umask and how to change the default value permanently?
Understanding Partition Scheme MBR vs GPT
How to find the path of any command in Linux
How to configure a Clustered Samba share using ctdb in Red Hat Cluster
How to delete an iscsi-target from openfiler and Linux
How to perform a local ssh port forwarding in Linux
How to do a case sensitive search inside vi editor in Linux
How does a successful or failed login process works in Linux


Viewing all articles
Browse latest Browse all 392

Trending Articles