Memory utilization as above = "-/+buffers/cache:used"/"mem:total" = 6293404/16333656
For the free command, the following formula is available:
Total = used + Free;
(-buffers/cache) used = mem:used-mem:buffers-mem:cached;
(-buffers/cache) used= (mem:total-mem:free)-mem:buffers-mem:cached
(+buffers/cache) Free = mem:free + mem:buffers + mem:cached
Therefore: (-buffers/cache) used memory: 6293404 = Real memory consumption
And +buffers/cache reflects the total amount of memory that can be appropriated, not the memory that is actually being used.
#!/bin/bash#test_memoryusageshellwhile: do phymem= ' free | grep "Mem:" |awk ' {print $} ' phymemused= ' Free | grep ' Buffers/cache ' | awk ' {print $} ' # echo $phymem # echo $phymemused awk ' begin{printf '%.2f%\n ', (' $phymemused '/' $phymem ') * ' sleep 3 done '
Use shell scripts to view memory usage on Linux