1

This question already has an answer here:

This is a 32 GB memory machine and the following top/free command says 30.5 GB memory is used, but the total RES is actually much less than 30.5 GB. Why?

top - 21:54:46 up 20 days,  1:46,  4 users,  load average: 0.59, 0.43, 0.34
Tasks: 238 total,   2 running, 233 sleeping,   0 stopped,   3 zombie
%Cpu(s):  3.8 us,  0.7 sy,  0.1 ni, 94.0 id,  1.5 wa,  0.0 hi,  0.0 si,  0.0 st
GiB Mem:    31.523 total,   30.609 used,    0.913 free,    0.456 buffers
GiB Swap:    4.000 total,    0.134 used,    3.866 free.   22.733 cached Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 2600 xxxxxxx   20   0 12.048g 2.002g 0.034g S   0.3  6.4  14:24.92 xxxxxx
 1443 xxxxx     20   0  1.302g 0.837g 0.019g S   0.3  2.7 102:19.93 xxxxxx
 9782 xxxxxxx   20   0  1.942g 0.573g 0.043g S  17.0  1.8 164:53.02 cinnamon
20730 xxxxx     20   0  0.619g 0.289g 0.055g S   0.3  0.9 102:19.50 xxxxxx
29920 xxx       20   0  0.787g 0.189g 0.020g S   0.3  0.6  60:42.72 xxxxxx
31377 xxxxxxx   20   0  3.390g 0.169g 0.006g S   0.0  0.5  38:45.66 xxxxxx
 9497 xxxxxxx   20   0  0.367g 0.168g 0.036g S   1.3  0.5  16:00.60 xxxxxx
 1402 root      20   0  1.010g 0.154g 0.024g S   0.3  0.5  54:30.61 xxxxxx
14176 root      39  19  0.306g 0.118g 0.011g S   0.0  0.4   4:32.76 xxxxxx
  903 xxxxxxx   20   0  0.383g 0.101g 0.034g S   0.3  0.3   0:43.40 xxxxxx

             total       used       free     shared    buffers     cached
Mem:            32         31          1          0          0         23
-/+ buffers/cache:          8         24
Swap:            3          0          3

The following ps command calculates total RSS, which is 7 GB, but top/free command returns 30.5 GB used. Why?

ps -e --format rss  | awk 'BEGIN{c=0} {c+=$1} END{print c/1024}'

My big mistake is this machine is actually 32 GB memory, not 64 GB.

marked as duplicate by Patrick, jasonwryan, thrig, Gilles linux Apr 14 '17 at 21:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Is it possible shared memory is 30.5 - 7 = 23.5 GB? The fork/copy-on-write behavior also cannot explain this. – Leonard Apr 14 '17 at 2:00
  • It says you have ~22G cache, so an RSS of 7 GB seems OK. The rest could be in buffers and shared – muru Apr 14 '17 at 2:34
  • "The fork/copy-on-write behavior also cannot explain this." -- why? – ilkkachu Apr 14 '17 at 8:52
  • @ilkkachu If you think it can explain, please explain it. – Leonard Apr 14 '17 at 17:41
0

It is because there is 22.7 cached Mem.

Here is my understanding.

total memory 
= used in topRow1 + free in topRow1 + buffers in topRow1 + cached in topRow2 
= used in freeRow2 + free in freeRow2

total RES in ps 
= used in freeRow2

Note that there is a DOT in topRow2.

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.