How is free calculation of used memory?

How to calculate used memory for free and why is it different from what / proc reports?

# cat /proc/*/status | grep VmSize | awk '{sum += $2} END {print sum}'
281260

But it says for free:

# free
             total       used       free     shared    buffers     cached
Mem:        524288     326488     197800          0          0          0

Who is right? Are you using 281260kb or 326488kb memory?

+3
source share
2 answers

The name asks: "How to calculate the used memory for free?"

Answer: he requests the OS, which must track this in order to do this work.

, . sheepsimulator , ​​Linux OS- /proc, , API free.

: " VmSize ?"

: , , .

  • Linux . char *p=new(1024*1024*1024*sizeof(char));, ​​ , . "", , . , OOM.
  • , .

, proc .

, free .

+6

"free" , ( , , !)

/proc/meminfo , "".

+1

Source: https://habr.com/ru/post/1724529/


All Articles