I am using System Monitor 2.28.0. When I look in the Resources tab, I see a nice graph with for memory and swap. Memory is about 60% 2.3 GiB of 3.8. When I type the command free, I got :
total used free shared buffers cached
Mem: 3994908 3962396 32512 0 100852 1477032
-/+ buffers/cache: 2384512 1610396
Swap: 8000328 28468 7971860
cat /proc/meminfo | grep MemFree give
MemFree: 34536 kB
The situation has remained the save for several minute. I started a lot of process with a script and the script is waiting for the free memory to get lower. According to what I am seeing in the Process tab (or with top), the number in System Monitor seem a lot closed to the total of the memory of the process that the one reported by free.
Thanks
The difference is whether or not the "buffers" and "cached" memory is included in the "used" count.
Generally, Linux system memory is used by the kernel for two purposes: processes and file/network cache/buffers. If you look closely at the output of
free
, it is already shown:If you add "buffers" and "cache", and then subtract that from the "used" column, you'll get the second line under "used" (the line that starts with
-/+ buffers/cache
), which shows about 2.3G (2384512) in use, which matches the reported memory in use that System Monitor is reporting (it is ignoring the buffers/cached because those will go away to make room for more processes).Your grep against
/proc/meminfo
actually matches the first line's "free" column (32512 is close enough to 34536 -- it likely changed between the two command outputs).When i got my hand on system-monitor, the memory usage reported in the "Resources" tab was the same than the
free
column in/usr/bin/free
.The problem is that the free physical memory is nearly 0, soon or later: Linux caches aggresively so the money you spent buying RAM is used efficiently. And this meant that the graph would constantly show >98% of memory usage, which was useless.
So i/we decided to do just like
-/+ buffers/cache:
line of/usr/bin/free
. This way, the graph is meaningfull and let the user watch the ~application/userland memory usage instead of the physical state of the memory.I know, this is a bit misleading, because most (l)users don't understand that free physical memory is a waste of money and performance. I faced the same problem at work: on every monday, servers would reboot, and in the next 24H, every server would trigger a "memory full" alert. So i had the free memory computation fixed in the supervision software just like in system-monitor.
Current Solaris has the same problem: the ZFS Cache (ARC) is not included in the free memory reported by tools like
vmstat
which makes stupid DB admins complains that "ZFS is bad" :)