LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Memory usage: what's telling the truth? (https://www.linuxquestions.org/questions/linux-general-1/memory-usage-whats-telling-the-truth-812328/)

DavidMcCann 06-05-2010 12:16 PM

Memory usage: what's telling the truth?
 
On my system, I get the following results for memory usage

"free" command: 210MB, 473 including buffers and cache
"top" command: 370MB
gnome-system-monitor: 180MB

So, what's the true story?

sycamorex 06-05-2010 12:27 PM

what's the exact output free -m?

DavidMcCann 06-06-2010 11:39 AM

I've just got this

bash-3.2$ free -m
total used free shared buffers cached
Mem: 1136 261 874 0 12 147
-/+ buffers/cache: 101 1034
Swap: 0 0 0

Evidently things are never the same two days running!

sycamorex 06-06-2010 11:43 AM

Your free memory is 1034. There was a really informative article about making sense of 'free' posted here on LQ some time ago. I can't seem to find it.

brucehinrichs 06-06-2010 09:52 PM

Was it this one?

http://www.linuxatemyram.com/

sycamorex 06-07-2010 01:44 AM

Quote:

Originally Posted by brucehinrichs (Post 3994901)

Yeah, thanks

DavidMcCann 06-07-2010 12:03 PM

I understand what "free" does. My point was that different tools disagreed with one-another.

In fact, a closer look at "top" and "free" shows they are in agreement. It's gnome-system-monitor that's out of step; it should show more memory in use than "free", as it's using memory to run, yet it shows less. The moral would appear to be "Beware of GUI tools and always trust your CLI."

Revery 06-09-2010 04:54 PM

What version of gnome-system-monitor are you using? In mine, when I look under the Resources tab, it shows 1.8GB used. When I type "free -m" it says 3852 (3.8GB) used, but 1807 (1.8GB) used for the "-/+ buffers/cache" row which is the one we really want. Top of course shows 3.8GB being used, and is scary (I don't like it). Basically my gnome-system-monitor is running correctly (at least to what the user wants to know). In Help->About I get version "System Monitor 2.28.0".

Additionally, you might want to look at ksysguard, which is the KDE process manager, which is good in its own ways (allows tree-view of process list and a few other cool things), but worse than gnome-system-monitor in others, and doesn't require you to be in KDE to use; you can just install it from the package manager.

ncsuapex 06-10-2010 07:35 PM

If you run top and you see these lines:

Mem: 2062712k total, 2010384k used, 52328k free, 248168k buffers
Swap: 0k total, 0k used, 0k free, 1619436k cached


MEM is the total memory you have. USED is used memory plus memory in cache. CACHED is memory that is not being used by an app but is in cache ready to use. So in my example 443276 is being used by the system.



At least this is how I interpret it. If Im wrong maybe someone will correct me.

syg00 06-10-2010 09:36 PM

This is closer to the correct description of buffers and cache.

johnsfine 06-11-2010 09:12 AM

Quote:

Originally Posted by syg00 (Post 3999687)
This is closer to the correct description of buffers and cache.

I read that up to the important, and I think incorrect, sentence:
Code:

SHR indicates how much of the VIRT size is actually sharable memory or libraries).
I have looked at /proc/pid/smaps in comparison to the SHR value reported by top. I have seen elsewhere that same claim that SHR is the sharable portion of VIRT. But when I actually look, SHR is way too low to be the sharable portion of VIRT.

I think SHR is the sharable portion of RES. I don't know how to tell for sure. But I haven't seen any cases that can be easily shown to contradict the idea that SHR is the sharable portion of RES.

I also dislike the sentence from that page
Code:

VIRT stands for the virtual size of a process, which is the sum of memory it is actually using
"Actually using" is ambiguous enough that I can't say flat out the above sentence is wrong. But that sentence is at least seriously misleading. VIRT typically includes a lot of "demand zero", "copy on write", and "untouched library pages", areas that are all memory the process hasn't used yet, isn't using now, and probably never will use.

Regarding the details of Buffers and Cache in that page, I don't know enough and/or didn't read carefully enough to comment on whether the page is accurate.


All times are GMT -5. The time now is 09:25 PM.