Memory usage

Preston Hagar prestonh at gmail.com
Mon Nov 29 19:58:22 UTC 2010


On Mon, Nov 22, 2010 at 2:14 PM, Cristopher Thomas <crisnoh at gmail.com> wrote:
> I'm not really sure how best to describe my problem, but I have a couple
> screenshots here that will hopefully help:
>
> http://dl.dropbox.com/u/1028931/htopOnBoot.png
>
> http://dl.dropbox.com/u/1028931/1DayLater.png
>
> Both screenshots were taken with approximately the same programs
> running, with the exception that in the 1DayLater shot I was running
> DockbarX instead of Docky.  Looking at the Memory usage indicator at the
> top left, you can see that the numbers are pretty close.  However, the
> bar indicator in the second shot shows that significantly more memory is
> being used that in the first.  What I'm trying to figure out is where
> the discrepency is coming from.
>
> Generally I only reboot my computer when an update has been installed
> that requires it.  However, since installing Maverick I've found that if
> I do that, after a few days the system starts slowing down and even
> freezing up occasionally.  Then I reboot and the cycle begins again.
>
> Based on my limited understanding of how memory is used, it seems to me
> that instructions are being cached, but somehow that space is not being
> made available later.  That was probably gibberish, but if you have a
> better idea of what is happening, help would be greatly appreciated.
>
> --
> Cris
>

To understand the discrepancy, see the htop FAQ (second question):

http://htop.sourceforge.net/index.php?page=faq

Basically, the bar is divided into 3 parts.  The first green part is
the memory in use, the blue section is buffers and the last brown
section is cache.  If you look at the numbers, 390  and 495, that is
only 105 extra MB in use, which especially taken in context of having
3 GB of ram, isn't that much.  It could be a could extra tabs in
Firefox depending on the sites you have open.

A common misconception is that you don't want a lot of free memory
just like you don't want extremely low CPU usage.  What is happening
is that the kernel is caching things in memory, under the idea that
you might open them again or access them again "soon".   This is a
good thing.  It means if you open OpenOffice, then close it and then
open it again, it won't take as long to load since it can (either all
or in part) be accessed from the cached section of memory, rather than
accessing the slow hard drive.  If a running app needs more memory and
there isn't enough left, it will free up the cache some and give that
memory over to the running process.

The fact that your swap usage is at 0 and that in both cases you still
have over 2.5 GB of RAM available, means that you aren't running into
any memory usage issues.  That said, I know you mentioned freezing or
things slowing down.  That might be happening, but it (at least from
just these two screenshots) doesn't look to be due to a lack of free
memory.

If you keep having the freezing/slowness, try to look at htop when it
is going slow and try sorting by CPU usage and see if something is
loading your CPU.  Your load average looks maybe a little bit high
(but not much) for a dual processor/core machine.  Generally, if a
machine load (stuff it is trying to do) is ideally matched with the
perfect processor for it, the load average should equal the number of
processors.  So, in your case, a load average of 2 would mean that the
cpu is being used in a "ideal" fashion (constantly in use without
overloading it).  In your screenshots, both have load averages over 2,
so since your memory looks generally good, it makes me wonder if the
slowness isn't perhaps in the CPU.  Here is a decent article on load
averages:

http://www.linuxjournal.com/article/9001

Anyway, I hope this maybe clears things up some.  I wouldn't worry
about the memory usage in particular, but rather look for CPU usage
and take a look at /var/log/syslog, mainly at the time periods of
freezing/slowdown.

Preston




More information about the ubuntu-users mailing list