Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

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:

             total       used       free     shared    buffers     cached
Mem:       3994908  **3962396**    32512          0   **100852**  **1477032**
-/+ buffers/cache:  **2384512**  1610396
Swap:      8000328      28468    7971860

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).

share|improve this answer
    
Thanks, I wonder why the system needed 1.5 Gig in cache, but that make it clear. –  Guillaume Coté Oct 27 '10 at 7:24
    
It's less a matter of "need" than of "used". At that point in time, it had read at least that much from the hard drive, and kept it in spare memory in case it needed to use it again. –  Kees Cook Oct 27 '10 at 17:45
add comment

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" :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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