I have two vm's one with 2vCPU , 4GB RAM and other with 4vCPU and 8GB RAM
Now I have installed / ran the same application(k8s pods) with same memory , cpu allocations , requests , limits on both the VM's.
Observations
- When dumping the entire top output on both vm's and summing up all process's Resident memory I get to see similar numbers on both VM's i.e around 2GB consumed.
- Summing up all the numbers under column VIRT gives
55456748more or less on both vm's
Question
- However in top command summary / process memory info commands shows different numbers on two VM's , Any pointers on why & where , how to find out the extra memory/root cause for memory consumption 4cPU and 8 GB ?
2VCPU 4GB
$ cat /proc/meminfo
MemTotal: 3880500 kB
MemFree: 144924 kB
MemAvailable: 590280 kB
SwapTotal: 1327100 kB
SwapFree: 1261564 kB4VCPU 8GB
$ cat /proc/meminfo
MemTotal: 8008964 kB
MemFree: 197860 kB
MemAvailable: 1470412 kB
SwapTotal: 1327100 kB
SwapFree: 1321408 kB 2 2 Answers
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:
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
} 2 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 1