[kde-linux] VM and Swap problems

Esben Mose Hansen kde at mosehansen.dk
Sun Jan 28 18:11:35 UTC 2007

On Sunday 28 January 2007 18:33:39 Randy Kramer wrote:

> > The VM and swap work fine till the swap space is half full.  But, after
> > swap is half full the system starts removing swap until it is exactly
> > half full.  When this happens, the VM system starts to thrash and the
> > system won't do anything till the thrashing stops.

512Mb swap? That's a fair amount of swapspace, more than you should need for 
desktop use. Maybe one of your applications leak memory (I have a webpage 
that makes konqueror leak insane amount of memory). Try checking with top 
what applications use lots of memory.

>    * Another possible workaround might be to drastically increase the
> amount of swap, so it is very difficult to reach the 50% usage figure.   (I
> originally couldn't decide whether my thrashing / slow response problems
> were at the 50% of swap figure, or swap usage ~= available RAM (because in
> most previous installations I installed (per the rule of thumb) swap equal
> to two times RAM.  In my most recent install, my swap is 3x RAM, and the
> slowed response still occurs at 50% swap usage.  (I'm not 100% sure the
> problem is thrashing, but it is as good a guess as any--the disk does see a
> lot of activity at this point.)

I can't see the scenario where adding lots of swap would really help. Having a 
bit of swapspace is nice because you can swap unused memory there, but once 
you have that bit swapped out, you won't gain much by adding more.

> Some other things I do:
>    * run as little as possible especially servers--for example, I do not
> run an MTA

Good advice, if mostly because running unneeded services is sort of pointless.

> Some other possible contributing causes (IMHO):
>    * I often wonder if this problem is partially a result of the
> (seemingly) Linux philosophy that memory not in use is wasted memory?  (For
> other reasons, I'd like to have a pool of memory that is not in use at any
> particular time, for example, so that when I go to start a new app, memory
> is immediately available for it.)

Unused memory will be used as disk buffers. This memory is, in practical 
terms, immediately available for applications. 

>    * Similarly, I wonder if this problem is partially a result of the Linux
> design of having one kernel (and memory handling philosophy, etc.) for both
> workstations and servers?  I'd really prefer to have memory handling
> customized for my use as a workstation rather than any bias that might
> exist towards handling it (memory) for a server.

I am not sure how to do this customizing. There are a number of out-of-mem 
handlers, but that is sort of different. Likewise, process scheduling and IO 
scheduling comes in several flavors, some of them useful for servers, some 
for desktop use.

> Another thing I don't like about Linux and its use of memory is (maybe it
> is mentioned above--maybe it is the unused memory is wasted memory
> philosophy) is the way it keeps expanding.
> Several times over the years I've drastically increased the amount of RAM
> memory in my systems (I mean like doubling, first, iirc, from 8 to 16 MB
> ;-)
> Each time I did that I initially did not change the distro (revision) I was
> using (so I could compare memory / swap behavior before and after the
> addition of RAM)--every time, with the same mix of applications, the RAM
> memory in use and the swap usage increased to fill the available memory to
> about the same percentage as before.  In some cases I did notice improved
> performance, in other cases it was so minor as to be undetectable (to me).

All memory gets filled in time, but most of the new memory should go to IO 
buffers, which isn't really taken, and is never swapped to disk. The 
command "free" reports buffers separately, e.g on my system right now:

esben at spurv:~$ free -m
             total       used       free     shared    buffers     cached
Mem:          1002        994          8          0        301        223
-/+ buffers/cache:        469        532
Swap:         3992          0       3992

Notice how it says 8 free, but then adds that with buffers, 532 is available 
for the system. The swap just tells you I have insane amounts of swap 
available, and use none. 

> Oh, wait, it had something to do with letting me have tools to control (or
> influence) the use of memory in *my* system.  Oh, and oh yes, I'm aware of
> and have experimented with swappiness.  That didn't seem very helpful to
> me--somewhere I have some notes, but it seemed that I either maintained
> about the same performance as before (i.e., the slowdown at 50% of swap in
> use), or started having crashes.  (Around this time I was using systems
> with 512 to 768 MB--the most my motherboards could handle.)

swappines is fun to play with, but I'd recommend just leaving it. It should 
automatically adjust in most distros.

> Anyway, at least now there are two of us who have seen problems along this
> line.  (Maybe if we both write to Linus he will do something to make things
> better ;-)

I think the real problem is that your memory (768Mb should be enough for most 
purposes) is filling up to the point where several hundred megabytes are in 
use. That's where  I would look... I haven't seen this unless I really was 
doing something huge.

kind regards, Esben

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

More information about the kde-linux mailing list