The "free" command does not display the correct values

7,711

You're looking at the wrong column. In the first output, the free memory i.e. the RAM available for new applications (without any swap usage) is shown in the available column. This correctly reports 3 Gb, or 3510224 Kb.

47 Gb - 43 Gb = (with rounding errors) 3 Gb

Linux borrows any unused memory for disk caching, that's why you see zero in the freecolumn. But the memory allocated for disk caching is released as soon as other applications request it.

Share:
7,711

Related videos on Youtube

yael
Author by

yael

Updated on September 18, 2022

Comments

  • yael
    yael over 1 year

    We have a very strange issue on one of our machine redhat 7.2.

    How it can be free - 0 , while used is 43 from total 47?

    [root@master ~]# free -g
                  total        used        free      shared  buff/cache   available
    Mem:             47          43           0           0           3           3
    Swap:             7           5           1
    [root@master ~]# free -k
                  total        used        free      shared  buff/cache   available
    Mem:       49552508    45570336      296216      237396     3685956     3510224
    Swap:       8093692     6053196     2040496
    

    From top:

    top - 17:34:40 up 10:39,  2 users,  load average: 0.77, 0.81, 0.83
    Tasks: 789 total,   1 running, 788 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  1.7 us,  0.4 sy,  0.0 ni, 97.7 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
    KiB Mem : 49552508 total,   831304 free, 45669236 used,  3051968 buff/cache
    KiB Swap:  8093692 total,  2056872 free,  6036820 used.  3412568 avail Mem
    
    • Stephen Kitt
      Stephen Kitt about 6 years
      A quick read of the manpage should clarify why this isn’t amazing.
    • igiannak
      igiannak about 6 years
      There is a detailed explanation on how ram is consumed and reported by free on linuxatemyram.com sometimes what we call free to be consumed linux calls it used but available to be consumed.