openSUSE 11.3 swap memory issue / possibly leak

Hello.

I noticed that after a while of working openSUSE 11.3 eats all swap memory and freezes.

What I’ve got:
RAM: 1 GB
Swap: 2 GB
(first partition on the hard drive)

Usually I open just Krusader, Opera, Thunderbird, gedit and some other minor programs.

Slowly but steady all the swap memory disappears. Even if I close all applications it won’t became available again.

After around 20 hours of uptime it looks like this:

linux-an6e:/ # free -m
             total       used       free     shared    buffers     cached
Mem:          1007        908         98          0         17        394
-/+ buffers/cache:        495        511
Swap:         2053       1803        250

The program «top» along with the «shift+m» shortcut gives me this information:

top - 06:00:41 up 16:55,  3 users,  load average: 0.05, 0.49, 1.05
Tasks: 145 total,   1 running, 144 sleeping,   0 stopped,   0 zombie
Cpu(s): 19.1%us,  8.9%sy,  0.0%ni, 68.6%id,  3.0%wa,  0.3%hi,  0.0%si,  0.0%st
Mem:   1031260k total,   929460k used,   101800k free,    20252k buffers
Swap:  2103292k total,  1847192k used,   256100k free,   413060k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                           
 1579 root      20   0 74968  14m 3840 S 13.6  1.5  80:19.83 Xorg                                                                              
 3105 johnny    20   0  101m  12m 6560 S 13.9  1.2   2:57.78 yakuake                                                                           
 2795 johnny    20   0  108m  11m 5400 S  0.0  1.1   4:09.91 main-menu                                                                         
 2717 johnny    20   0  138m  10m 5964 S  0.0  1.0   0:48.22 nautilus                                                                          
 2405 johnny    20   0  112m 9972 4916 S  0.3  1.0   3:27.42 gnome-panel                                                                       
 2371 johnny    20   0 29416 5440 3068 S  0.0  0.5   1:16.79 gtk-window-deco                                                                   
 2008 johnny    20   0  164m 5236 2884 S  0.7  0.5   1:58.14 gnome-settings-                                                                   
 2372 johnny    20   0 37356 4028 1380 S  1.3  0.4  12:06.42 compiz                                                                            
 3458 johnny    20   0 42984 3640 2552 S  0.0  0.4   0:01.51 klauncher                                                                         
 3527 johnny    20   0 83928 3320 2124 S  0.0  0.3   0:03.67 kglobalaccel                                                                      
 3100 johnny    20   0 92536 3288 1696 S  0.3  0.3   2:07.21 parcellite                                                                        
 1930 johnny    20   0  9644 2604 1060 S  0.3  0.3   0:04.69 gconfd-2                                                                          
10901 johnny    20   0 90196 2492 1240 S  0.3  0.2   0:03.36 kwalletd                                                                          
21056 johnny    20   0 39724 2432 1580 S  0.0  0.2   0:00.04 kio_file                                                                          
 7680 johnny    20   0 83448 2228 1464 S  0.0  0.2   0:02.78 knotify4                                                                          
 2087 johnny    20   0  117m 2088 1136 S  0.0  0.2   2:45.09 pulseaudio                                                                        
 3465 johnny    20   0 84788 1864 1232 S  0.0  0.2   0:04.58 kded4                                                                             
 3089 johnny    20   0  160m 1816  904 S  0.0  0.2   0:05.57 nm-applet                                                                         
20419 johnny    20   0  5356 1740  808 S  0.0  0.2   0:00.64 bash                                                                              
 3095 johnny    20   0 34448 1712  960 S  0.0  0.2   0:01.29 python                                                                            
 2794 johnny    20   0 28220 1664 1072 S  0.3  0.2   1:02.56 multiload-apple                                                                   
 1795 johnny    20   0 30032 1608 1076 S  0.0  0.2   0:01.03 gnome-session                                                                     
 3085 johnny    20   0  167m 1492  800 S  0.0  0.1   0:01.39 gpk-update-icon                                                                   
 3099 johnny    20   0  156m 1368  712 S  0.0  0.1   0:01.40 gnome-volume-co

It says that nothing consumes the memory. Why then is almost the whole swap used?

After working another several hours the swap memory gets fully used, with 0 free megabytes left.

Right after that a process named kswapd0 boosts the load average level to the max and causes the system to freeze.

I even tried to reinstall openSUSE but it didn’t help. I thought it could be some opera or skype memory leaks but one of my friends uses Debian with exactly same programs on the same daily basis and never faced such problems. I also doesn’t remember such swap issues in earlier openSUSE versions.

Does anybody have a clue what’s going on? Or maybe even somebody else noticed such swap leaks?

Johnny151 wrote:

>
> Hello.
>
> I noticed that after a while of working openSUSE 11.3 eats all swap
> memory and freezes.
>
> What I’ve got:
> RAM: 1 GB
> Swap: 2 GB
> (first partition on the hard drive)
>
> Usually I open just Krusader, Opera, Thunderbird, gedit and some other
> minor programs.

You’re putting 10 pounds of crap in a 5 pound bag :wink:

Seriously, if you watch swap as you open each app you should see your swap
file start to grow somewhere around Thunderbird, give or take, as each
program of the first two wants x amount of memory beyond the base runtime
code. When Thunderbird loads your email database, it uses even more. Every
web site Opera visits takes some memory. Likewise with all the rest, so you
eat up a bunch of memory - likely more than your RAM size - just with the
base program load before they ever begin to use working space. Watch the
disk activity as you switch apps. Now, lets say you visit a web site that
grows swap then close that site and go to another that uses some more. If
you need to use more swap space than is free while retaining some pre-
determined amount of the last site in the cache (from your top info), swap
will grow as the system makes more space available. Even if you close some
like Opera, the used swap space will remain assigned rather than being
deleted by moving the stuff on swap back to live memory until the swapped
portion is needed so swap stays the same. The system knows what it can re-
used as needed so why waste time shuffling memory until it has to? I run a
lot of database stuff that will use several gig of swap even with 4GB of RAM
and the swap file only shrinks very gradually, if at all, when I close the
database.

The only thing that matters is if the system finally tells you that you are
out of memory which only happens when it has reused as much
cache/buffer/swap memory as possible and you still don’t have enough. It
won’t decrease the memory it assigns to cache/buffer/swap usage until it has
to.


Will Honea

Thank you for the answer, Will Honea.

Can you say please whether it’s possible to force openSUSE to free the whole swap memory used by an application which was closed? Or at least to determine a certain percentage of the swap memory that could be cached? Now I understood the caching mechanism but still after around 24 hours of active work when the swap memory is 100% full the system freezes. That’s sad because my friend with (desktop) Debian has the same amount of memory (1GB RAM and 2GB swap) on his computer and claims everything is ok. I also remember there were no such problems in previous openSUSE versions.

And an another example. Our Debian server (VPS) runs already for several months but the swap file doesn’t grow there, it’s around 15-25% of its full capacity (of 512 MB). Debian shrinks it or increases if necessary. And that’s a server with only 256 MB RAM and several thousands visitors a day. I use there a MySQL database of around 1 GB disk space (when dumped).

Is it possible somehow to determine the behaviour of openSUSE’s swap caching mechanism the same as by Debian? Which settings’ files should I compare, those from /proc/sys/vm/ ?

It shouldn’t be freezing.

At one time, I had such freezing problems on a solaris system. It turned out to be a failing disk. The errors were not logged, because the system could not write logs to the failing disk.

I don’t know whether that is a problem in your case. However, perhaps it’s worth considering as one possibility.

On 2011-02-23 06:06, Johnny151 wrote:
>
> Hello.
>
> I noticed that after a while of working openSUSE 11.3 eats all swap
> memory and freezes.
>
> What I’ve got:
> RAM: 1 GB
> Swap: 2 GB
> (first partition on the hard drive)

Maybe it is not enough swap. I’d like 4 GiB minimum.

> Usually I open just Krusader, Opera, Thunderbird, gedit and some other
> minor programs.

In my system, firefox is using about 2 GB, and Thunderbird 1 (virt column
in top).

Use top sorted by memory (type uppercase “M”), some memory eaters could be
hiding at the bottom.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

On Wed, 23 Feb 2011 18:36:02 +0530, nrickert
<nrickert@no-mx.forums.opensuse.org> wrote:

>
> It shouldn’t be freezing.
>
> At one time, I had such freezing problems on a solaris system. It
> turned out to be a failing disk. The errors were not logged, because
> the system could not write logs to the failing disk.
>
> I don’t know whether that is a problem in your case. However, perhaps
> it’s worth considering as one possibility.
>

i’d also suspect hardware issues rather than insufficient memory. not too
long ago i was running a similar system, with only 1GB of RAM, and while
things got painfully slow, it continued to run and swap use didn’t
increase to a point of no return on openSUSE.


phani.

Opera can be a real memory hog, particularly if you open lots of tabs. I know, because I do…

More generally, I used to have this problem. Originally I didn’t have enough swap on my laptop (1.6 G); this primarily showed on crashes involving suspend and resume, but when I added another 1.6 G of swap, those went away. However, the machine would still grind to a halt, more or less. Buying more ram cured that and while maybe it wasn’t absolutely necessary, I did have some stuff coming up where I thought that I would genuinely need more ram, so for me it didn’t make much sense to keep putting off the inevitable.

Johnny151 wrote:

> Now I understood the caching mechanism but still after around 24
> hours of active work when the swap memory is 100% full the system
> freezes.

I missed the freeze part originally but others caught it and I have to agree
with them: you need more memory be it virtual (swap) or real (RAM). Swap
space is cheaper.

Personally, I wouldn’t try to run what you have with only 1GB of RAM - I
have better things to do with my time than waiting on the inevitable
swapping between the swap file and real memory. oS 11.3 sucks up nearly
400M just to wake up and Firefox wants even more with a single blank screen.
Anything more will require swapping back and forth - the disk activity light
starts to be a constant on feature and the system has very few resources to
work with to implement features like cache and buffering to speed things up.
Another homily comes to mind: you can’t get blood out of a turnip.


Will Honea

Thank you for your answers.

As I understand, possible solutions are those:

  1. Buying more memory.
    I’m was going upgrade my computer soon. Though I think 1 GB of current RAM is still very much and it would surprise me if it was the reason for the issue.

  2. Hardware issues.
    The same hard disk with the swap partition I use for all other files, most likely it’s working normally.

  3. Increasing swap memory.
    Done, let’s see.

And the last one point, I suppose, I must dig deeper into the openSUSE’s mechanisms but it will take some time because I’m a web-developer, not a linux programmer. I really want to know what’s going on with it. As a temporary solution I enlarged the swap memory and added to /etc/sysctl.conf such lines:

Less use of the swap memory

vm.swappiness = 10

Now the value in /proc/sys/vm/swappiness is 10 instead of a standard 60 right after the system start and the swap memory grows way much slower.

On 2011-02-26 20:36, Johnny151 wrote:

> 3. Increasing swap memory.
> Done, let’s see.

You need about 4 Gigs between swap and ram. Linux is a memory hungry system.

> # Less use of the swap memory
> vm.swappiness = 10
>
> Now the value in /proc/sys/vm/swappiness is 10 instead of a standard 60
> right after the system start and the swap memory grows way much slower.

You should not do that. That’s two changes.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

Sorry, I didn’t understood your last message concerning vm.swappiness.

On 2011-02-27 10:06, Johnny151 wrote:
>
> Sorry, I didn’t understood your last message concerning vm.swappiness.

When you do not know the cause of a problem, don’t apply two changes to
correct it, apply only one. If it works, that was it. If it doesn’t, then
apply the other.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)