On Fri, Sep 21, 2001 at 11:21:10AM +1000, Keiran Sweet wrote:
> Hi,
> I currently have a 133Mhz Pentium system with 64MB RAM acting as my home
> network internet gateway, running RH 7.1 with the stock 2.4.2-2 Kernel
> I have recompiled the kernel to disable modules, statically include the
> network card drivers, and all other hardware drivers, plus include all
> needed netfilter support.
> All of this managed to get the kernel size down from about 2 megs(plus
> modules) to about 722k. My question is why i am constantly noticing that

Note that modules don't impose any significant overhead beyond that of
building features into the kernel, so you could've gotten the same
improvement by leaving everything modular.  The main improvement either
way comes from disabling things you don't need.

> the systems memory is always
> becoming highly used, upon boot it uses 17megs of the 64 availiable, and
> i'll check back a day later to see it using about 62 megs of memory.
> I have asked a few people about this, and they have advised me that its
> due to HDD caching ect, ie, more writing/reading activity the more RAM
> is used...

This sounds quite likely to me as well.

> I have looked through a few books and havent been able to find much
> information on how memory is used ect under linux systems, and am a bit
> concerned that a basic system which does
> packetfiltering and forwarding, and runs only sshd besides some other
> system dependant daemons would use so much memory...
> 
> If anyone could shine a bit of light on this issue it would be great.

Ok.  I'm guessing you're reading the output of the "free" command to
judge how much RAM is free?  If so, let's take a closer look... here's
what mine looks like at the moment.

bash-2.05$ free
             total       used       free     shared    buffers    cached
Mem:        127100     124296       2804          0       2428     61276
-/+ buffers/cache:      60592      66508
Swap:       130748      41052      89696
bash-2.05$ 

As you can probably guess from this, my system has 128Mb of ram, and the
same again in swap.  Also, you might notice the value under "free" is
2804 -- not even 3Mb!

But that's not the whole story.  That represents the amount of memory
that is completely unused by anything on my system.  If you look further
along that line, you can see that buffers is 2428, and cached is 61276.
That means I've got over 60Mb of RAM devoted entirely to caching disk
access (both read and write).

Now the interesting bit is the second line.  It's a bit confusing --
what the hell is "-/+ buffers/cache" supposed to mean?  Well, it's
letting you know that this line is the same as above, except it is
*subtracting* the buffer and the cache memory from the "used" value, and
*adding* them to the free value.

So I have 66508Mb free when the buffers and cached values are taken into
account.  Considering I'm running mozilla, x-chat, etc, that sounds
reasonable.

The "Swap" line is just a straightforward description of how much swap
space is used and available.

The reason why the second line matters is that Linux will automatically
adjust the buffers and cache according to what your system is doing.  If
there aren't many programs in memory, it will use the remaining memory
to cache things.  If a program is in memory but hasn't been used for a
long time, it may even swap it out to get more room for cache.  But as
soon as a program requires more RAM than is available, it will happily
cut back on the cache memory so that the program can work.

So the second line shows how much memory is available for use by new and
existing processes, and this is what most people intuitively think of as
"free memory".

Other ways of finding out about memory usage on your system include:
  * Running the command "top"
  * cat /proc/meminfo

I hope I've helped explain what's going on, and that I didn't patronise
you by telling you things you already knew.  If I did, please let me
know and I'll try to do better next time.

And definitely let the list know if you're still confused (or more
confused :)

This is the sort of basic information that really should be explained in
the man page for "free" where newbies can find it, but isn't.

Regards,

-Andrew.

-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to