[techtalk] Memory Usage

Kelly Lynn Martin kelly at poverty.bloomington.in.us
Tue May 23 21:42:15 EST 2000


On Tue, 23 May 2000 21:36:27 -0400 (EDT), Beverly Guillermo <mezanin at home.com> said:

>Here's my scenario -- I start my linux box and check my available
>memory space with 'free' and get the following:

>-------------------------------------------------------------------------
>             total       used       free      shared    buffers    cached
>Mem:        258104      38564     219540      12108       6872      22504
>-/+ buffers/cache:       9188     248916
>Swap:       128516          0     128516
>-------------------------------------------------------------------------

>and when start another program, then exit, and check 'free' I get.

>-------------------------------------------------------------------------
>             total       used       free     shared    buffers     cached
>Mem:        258104      50932     207172      12888       8308      32672
>-/+ buffers/cache:       9952     248152
>Swap:       128516          0     128516
>-------------------------------------------------------------------------

>Am I reading this wrong?  Shouldn't I get back the memory I used when the
>program exits/terminates?  

You do.  Notice that you're using 2M more in buffers and 10M more in
cache.  "Buffers" is memory that's storing discardable data read from
disk on the presumption that it might be needed again soon.  "Cache"
is memory that's storing pure code (programs or shared libraries)
which is not currently being used but may again be needed soon.  Linux
keeps stuff like this in memory until the memory is needed for
something else.  People tend to do the same thing over and over again,
and keeping stuff in memory makes the system run faster.  Memory is
much faster than disk.  Your actual usage only went up about 800K --
which is probably memory being used by some daemon or by X.  Your
shared usage went up by almost the same amount, suggesting that most
of this is a shared library.

>Is there a better program to check memory usage?  If so, what is it?

>Of all the years I've used linux, I could never figure out what is going
>on with memory usage.

Linux memory management is not simple.  It's not just a matter of
'load the program, run the program, throw the program away' like it is 
with other, more primitive, operating systems.

Kelly





More information about the Techtalk mailing list