• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • What is buffers/cache in free command in Linux ?

    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

    What is buffers/cache in free command in Linux ? What is buffers/cache in free command in Linux ? Reviewed by admin on Sunday, February 22, 2015 Rating: 5

    No comments:

    Powered by Blogger.