Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 02-09-2012, 06:48 PM   #1
LQ Newbie
Registered: Jan 2012
Posts: 2

Rep: Reputation: Disabled
(Large) Memory usage discrepancy between top and gnome-system-monitor

[I found an old thread relating to this, but the only reply was a dead article link, along with some silly threads where the distinction between GiB and GB was apparently misunderstood.]

I've noticed this on a several machines and a few different distributions of GNU/Linux (including Fedora and Ubuntu): The used memory reported by top (or 'free -m' -- they always agree) is significantly higher than that reported by gnome-system-monitor. For example, on the Fedora 16 system from which I'm typing this, top reports...

top - 18:07:28 up 17 days, 14:25,  3 users,  load average: 0.36, 0.31, 0.30
Tasks: 188 total,   3 running, 185 sleeping,   0 stopped,   0 zombie
Cpu(s):  6.9%us,  1.6%sy,  0.0%ni, 91.2%id,  0.0%wa,  0.2%hi,  0.1%si,  0.0%st
Mem:  12049356k total,  8791056k used,  3258300k free,   432116k buffers
Swap: 14155772k total,    23208k used, 14132564k free,  6268156k cached
...meanwhile gnome-system-monitor says "Memory: 2.0 GiB (17.4 %) of 11.5 GiB".

The gui's report makes much more sense given the load on the system (just a bunch of firefox tabs, a couple terminals, and gnome-system-monitor itself running on Gnome 3).

My suspicion (perhaps having spent a bit too much time coding in C lately) is that top is only aware of memory usage from the perspective of the kernel -- from which glibc's malloc() implementation checks out large blocks via calls to sbrk() or whatever and then doesn't return that memory to the kernel when it's freed, opting instead to keep it around for future calls to malloc() (since sbrk() calls are relatively expensive). If gnome-system-monitor is aware of all available memory, including the memory that's been freed but not returned to the kernel, that's really cool. I'd love to know how to get at that information in a terminal. After all, isn't that what one should actually be interested in from an administrative point of view?

Stepping back a bit, the effect is so dramatic that I'd be surprised if it were actually to do with malloc(), but Linux surprises me (usually pleasantly) all the time. Anyway if someone who knows what's really going on here could set me straight or confirm my suspicions, I'd really appreciate it.

Old 02-09-2012, 09:03 PM   #2
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,870

Rep: Reputation: 2189Reputation: 2189Reputation: 2189Reputation: 2189Reputation: 2189Reputation: 2189Reputation: 2189Reputation: 2189Reputation: 2189Reputation: 2189Reputation: 2189
This is such an old chestnut. Apples and Oranges.
Have a look at the second line of the "free" output - that is the "total" minus {page}cache usage. See how that compares to the GUI.
Old 02-09-2012, 09:58 PM   #3
LQ Newbie
Registered: Jan 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
HAH, thanks for the palm-to-face realization. 'Tis the problem with learning in relative isolation -- sometimes I need somebody to point out the obvious.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory usage using TOP FantaJ Linux - Newbie 2 03-05-2008 12:35 PM
memory reporting: top vs. system monitor jhwilliams Fedora 1 08-17-2007 11:42 AM
gnome system monitor shows different resource usage than top BCarey Linux - Software 0 02-13-2007 10:14 PM
Wrong memory info in gnome-system-monitor after 2.6.6 kernel upgrade corezapr Linux - Software 1 06-14-2004 03:57 AM
Memory usage reported using TOP Kdiver58 Linux - Newbie 1 02-03-2003 01:31 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:42 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration