I want to know why psutil's virtual memory used or active do not match the value I get from the linux command 'free -m' What I want to know is the physical system memory used.
virtual_memory().total / 1024 / 1024 = 29741
virtual_memory().used / 1024 / 1024 = 7967
virtual_memory().active / 1024 / 1024 = 2259
total used free shared buff/cache available
Mem: 29741 1148 21773 16 6819 28322
Swap: 0 0 0
I'm guessing that virtual_memory().used returns physical mem + shared mem + cached mem but still, active memory should match 1148.
virtual_memory().used
includes buffers and cache. There are actually articles on the net on how to correctly interpret the output of thefree
command regarding that topic in general. To get the actually used RAM (without buffers etc.), usepsutil.virtual_memory().total - psutil.virtual_memory().available
. – Poppy.active
is indeed OS dependent (UNIX). See pythonhosted.org/psutil/#memory – Poppy