[ale] Memory Usage

Eric Z. Ayers eric.ayers at mindspring.com
Sun Jun 20 11:22:45 EDT 1999


First of all, You say taht you are 'running out of memory'  how are
you determining this?

We have a machine with 512MB of RAM and the thing always shows that it
has very little free RAM.  


cat /proc/meminfo
        total:    used:    free:  shared: buffers:  cached:
Mem:  529731584 526450688  3280896 131284992 66248704 114561024
Swap: 1052540928 91131904 961409024
MemTotal:    517316 kB
MemFree:       3204 kB
MemShared:   128208 kB
Buffers:      64696 kB
Cached:      111876 kB
SwapTotal:  1027872 kB
SwapFree:    938876 kB                                    


But, look at the 'cached' number.  That is your filesystem cache.
Linux is trying to make the most of your RAM by using the RAM that is
not needed for executing code and storing data for a filesystem
cache.  This includes the executable code for your programs which it
doesn't have to load them into memory unless the code is actually
executing, but it might choose to leave them in RAM if there is room.

Swap space is only needed for memory that your programs has written to 
(data segments), so you might not see much going to swap even if your
system is very busy.  It might be doing a lot of disk accesses to load 
in executable program code.  Programs like Emacs are very hard on your 
computer because a lot of the code is actually stored in the data
segment, not compiled into machine instructions which it can page off
of the disk on demand, and just delete from memory when not needed any 
more.

To answer your question about programs you don't need:

automount - only needed if you are using automount NFS
portmap   - only needed if you are using NFS or other RPC protocols
sendmail  - not needed for many email setups
lpd       - only needed if you are printing

You could remove these daemons from the startup, but it might not make 
much difference.

The reason why some of your stuff has been swapped out is because 
some program started early in the boot cycle (like init), then all of
the startup scripts ran, so the OS swapped out data segments (from init
or other programs) which were still a part of active processes but
hadn't been used recently.  Now, the most recently accessed memory
from your filesystem and programs that have run recently 
are sitting around in cache, while those data segments are still
sitting out in swap.  And why shouldn't they? they aren't being used,
and may never be used again!

In summary, let me just point out that 24M of RAM is not very much if
you start up X in >8bit color mode and then start a copy of netscape.
This  is probably what most people do right off the bat when they
start up their computers.  On the machine above, each invocation
of netscape uses > 10MB of RAM resident in memory.  My X server also
uses 10 MB of RAM resident in memory:

ps auxww 

USER       PID %CPU %MEM  SIZE   RSS TTY STAT START   TIME COMMAND 
...
   
doofus    14806  1.4  2.1 30532 10900  ?  S   Jun  9 231:40 /usr/lib/netscape/netscape-communicator   
twit      24641  1.8  2.2 26572 11468  pb S   Jun 17  74:12 /usr/lib/netscape/netscape-communicator /usr/doc/HTML/index.html 
root        422  0.0 14.9 22372  9416  ?  S   Jun 14   2:01 /etc/X11/X -bpp 16  

So these 2 programs want 20MB if they can get it.  


-Eric.


Michael B Golden writes:
 > My system continually runs out of memory. It has 24M RAM in it and a 64M
 > (I set it as 64, but the number reported by free seems to be different.
 > Go figure.)  Swap Partition. It never has used more than 10M of the Swap
 > ever. Even when I'm not running anything but the daemons, it uses a lot.
 > Is this normal?
 > 
 > Output of ps ax :
 >   PID TTY STAT TIME COMMAND
 >     1  ?  S    0:02 init
 >     2  ?  SW   0:00 (kflushd)
 >     3  ?  SW<  0:06 (kswapd)
 >     4  ?  SW   0:00 (md_thread)
 >     5  ?  SW   0:00 (md_thread)
 >    36  ?  S    0:00 /sbin/kerneld
 >   173  ?  S    0:00 syslogd
 >   182  ?  S    0:02 klogd
 >   204  ?  S    0:00 crond
 >   216  ?  S    0:00 (inetd)
 >   228  ?  S    0:00 (lpd)
 >   252  ?  S    0:00 /usr/sbin/automount --timeout 60 /misc file
 > /etc/auto.misc
 >   271  ?  S    0:00 sendmail: accepting connections on port 25
 >   316   5 S    0:00 (mingetty)
 >   318  ?  S    0:01 update (bdflush)
 >   319   6 S    0:00 (mingetty)
 >   725   4 S    0:00 /sbin/mingetty tty4
 >   727   3 S    0:00 /sbin/mingetty tty3
 >   729   2 S    0:00 /sbin/mingetty tty2
 >   731   1 S    0:01 -bash
 >   743   1 R    0:00 ps ax
 >   159  ?  S    0:00 (portmap)
 >   193  ?  S    0:00 /usr/sbin/atd
 > 
 > Output of free :
 >              total       used       free     shared    buffers     cached
 > Mem:         22724      16444       6280       3328       1624      12708
 > -/+ buffers/cache:       2112      20612
 > Swap:        72256        896      71360
 > 
 > This test was performed with only one user logged in running nothing
 > except that listed above. Do I really need all of that running? If not,
 > which can I remove? (I'm not even sure what it all is). It is important,
 > because I keep pushing it and having to flip the switch on it because I
 > manage to freeze it by stuffing too much into memory. I don't have the
 > money to stick more RAM into it, so that isn't an option, and it doesn't
 > care to use the swap very often. What can I do?
 > 
 > ---------------------------------------------------------------------------------------------------------------------
 > Michael Golden
 > Naugrim at Juno.com (Normal, no attachments)
 > MGolden at Airapps.com (Only for messages with attachments.)
 > RedHat 5.2 (2.0.36) Linux user -- Linux Advocate
 > 
 > ___________________________________________________________________
 > Get the Internet just the way you want it.
 > Free software, free e-mail, and free Internet access for a month!
 > Try Juno Web: http://dl.www.juno.com/dynoget/tagj.






More information about the Ale mailing list