How to infer top command VSZ & Resident memory numbers active usage / free?
Do not use MemFree
, but instead use the MemAvailable
metric to determine the amount of "free" memory the system can use for applications without going to swap.
A detailed explanation for this is given here, for example:
https://superuser.com/questions/980820/what-is-the-difference-between-memfree-and-memavailable-in-proc-meminfo
I have written the following Bash function for general memory usage inspection. You can insert the code to the end of your .bash_aliases
file.
function mf
{
mt=($(grep '^MemTotal:' /proc/meminfo))
ma=($(grep '^MemAvailable:' /proc/meminfo))
let mtmb=${mt[1]}/1024
let mamb=${ma[1]}/1024
let mumb="(${mt[1]}-${ma[1]})/1024"
let muse="(${mt[1]}-${ma[1]})*100/${mt[1]}"
st=($(grep '^SwapTotal:' /proc/meminfo))
sf=($(grep '^SwapFree:' /proc/meminfo))
let stmb=${st[1]}/1024
let sfmb=${sf[1]}/1024
let sumb="(${st[1]}-${sf[1]})/1024"
if (( st[1] != 0 )) ; then
let suse="(${st[1]}-${sf[1]})*100/${st[1]}"
else
suse=0
fi
printf "%17s%10s%10s%6s
Memory %9sM%9sM%9sM%5s%%
Swap %9sM%9sM%9sM%5s%%
" 'Total' 'Used' 'Av/Free' 'Use%' \
$mtmb $mumb $mamb $muse \
$stmb $sumb $sfmb $suse
}
OK , This was due to hugepages configuration that i've set while installing an application , OS creates the pages apparently based on values specified while enabling them.
2VCPU
around 600 pages with each 2048k i.e 1.23 GB locked
4 vcpu
around 2048 pages with each 2048k i.e 4.2 GB locked in main memory