civileme,

Thanks for the explanation -- very helpful and understandable!  Could
you carry it one step further and explain a little more about the use of
swap.  When I reboot Linus (Mandrake 7.2) on my system with 128 MB RAM
(and 300 MB swap), initially there is some unused RAM and no swap is
used.  As you describe, gradually (not very long actually), almost all
of my memory is used and then I start to see swap usage.  The swap usage
gradually climbs -- right now I'm at about 190 MB used -- is there a
point when I should start to worry about swap usage?

Randy Kramer

civileme wrote:
> People who monitor their resources in Windows and know they have to
> rebootwhen the memory available drops low are often confused by linux.
> 
> When things start off, linux loads programs and usesz the memory for them.
> Very soon the programs are reading from and writing to disk, so buffers are
> assigned
> 
> (It is silly to step the heads to the other end of the disk when we have 20
> writes queued for no more than three cylinders from the current position and
> two reads or writes about 2000 cylinders away, so sometimes items bound for
> disk can wait in memory a while.
> 
> This is no problem for the system, it makes a buffer to hold the pending disk
> writes and bides its time for the opportunity of for the user to force action
> with a 'sync' instruction.
> 
> KDE continually writes some information to disk, like the current positions
> of open windows, so that they can be restored in future sessions if the user
> elects that option.  The system simply allocates memory for that so the free
> memory shrinks (sort-of).  Actually, if a program requests some memory from
> the system and there isn't enough, some of the big disk buffers get flushed
> to disk and the system hands the program the required memory.
> 
> The result is that with the system and KDE running with a cvouple of app
> programs, 40-80Mb might be a good starting number for memory usage.  It will
> inevitably grow to fill 95% or so of memory capacity as the system tries to
> page disk operations efficiently and share memory and logic between programs.
> 
> In windows this could be a memory leak.  I have seen WINE running a windows
> program viciously kill the program because it allocated memory and didn't
> free it.  Linux has more safeguards against memory leaks by far than windows
> does.
> 
> But also, unused memory is considered _wasted_ memory by the many designers
> of linux.  Since things are faster by a factor of 40 or more if some of
> memory is used to act like disk storage, it is a common practice to include
> such algortithms in the kernel.
> 
> In other words, if linux is using 121 of 128 Mb, that is great.  If you
> upgrade to 512 Mb and find that after a couple of hours linux has used 490 Mb
> that is wonderful.
> 
> Use the 'free' instruction from a console or Konsole or Xterm to see what is
> used, what is buffer, what is shared and what is cache (to make web pages
> load faster and such).  It will surprise you.
> 
> Civileme
> 
>     ---------------------------------------------------------------
> Want to buy your Pack or Services from MandrakeSoft?
> Go to http://www.mandrakestore.com

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to