SWAP memory

Though I have a 2gb swap memory partition on my apache server it does not appear to be using it as when the normal memory gets full the server crashes.

Any clues or guidance as to how to correct this would be gratefully received!

while waiting for a guru to happen along, why not give us some
details about your system’s hardware and software…

is it one particular application that is running up the mem use…

and, how about running this from a terminal command line

top -n1 >> ~/top.txt

and copy/paste it into that message…


DenverD (Linux Counter 282315) via NNTP, Thunderbird 2.0.0.14, KDE
3.5.7, SUSE Linux 10.3, 2.6.22.18-0.2-default #1 SMP i686 athlon

Processor (CPU): AMD Sempron™ Processor 3000+
Total memory (RAM): 1.92 GB
System: openSUSE 10.2 (i586)

I hope this makes sense to someone…

H2J(Bmtop - 18:46:06 up 9 min, 3 users, load average: 1.87, 1.80, 1.08(Bm39;49mK
Tasks:(Bm39;49m(Bm 123 (Bm39;49mtotal,(Bm39;49m(Bm 2 (Bm39;49mrunning,(Bm39;49m(Bm 120 (Bm39;49msleeping,(Bm39;49m(Bm 0 (Bm39;49mstopped,(Bm39;49m(Bm 1 (Bm39;49mzombie(Bm39;49mK
Cpu(s):(Bm39;49m(Bm 24.5%(Bm39;49mus,(Bm39;49m(Bm 4.3%(Bm39;49msy,(Bm39;49m(Bm 0.0%(Bm39;49mni,(Bm39;49m(Bm 2.0%(Bm39;49mid,(Bm39;49m(Bm 68.8%(Bm39;49mwa,(Bm39;49m(Bm 0.3%(Bm39;49mhi,(Bm39;49m(Bm 0.1%(Bm39;49msi,(Bm39;49m(Bm 0.0%(Bm39;49mst(Bm39;49mK
Mem: (Bm39;49m(Bm 2010296k (Bm39;49mtotal,(Bm39;49m(Bm 990820k (Bm39;49mused,(Bm39;49m(Bm 1019476k (Bm39;49mfree,(Bm39;49m(Bm 22488k (Bm39;49mbuffers(Bm39;49mK
Swap:(Bm39;49m(Bm 2104472k (Bm39;49mtotal,(Bm39;49m(Bm 0k (Bm39;49mused,(Bm39;49m(Bm 2104472k (Bm39;49mfree,(Bm39;49m(Bm 591500k (Bm39;49mcached(Bm39;49mK
6;1H
7m PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND (Bm39;49mK
(Bm(Bm 3772 root 18 0 192m 157m 7784 R 2.0 8.0 0:37.20 parse-metadata (Bm39;49m
(Bm 1 root 15 0 740 284 240 S 0.0 0.0 0:01.21 init (Bm39;49m
(Bm 2 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 (Bm39;49m
(Bm 3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0 (Bm39;49m
(Bm 4 root 10 -5 0 0 0 S 0.0 0.0 0:00.11 events/0 (Bm39;49m
(Bm 5 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 khelper (Bm39;49m
(Bm 6 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kthread (Bm39;49m
(Bm 9 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kblockd/0 (Bm39;49m
(Bm 10 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kacpid (Bm39;49m
(Bm 11 root 12 -5 0 0 0 S 0.0 0.0 0:00.00 kacpi_notify (Bm39;49m
(Bm 104 root 20 -5 0 0 0 S 0.0 0.0 0:00.00 cqueue/0 (Bm39;49m
(Bm 105 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kseriod (Bm39;49m
(Bm 147 root 25 0 0 0 0 S 0.0 0.0 0:00.00 pdflush (Bm39;49m
(Bm 148 root 15 0 0 0 0 S 0.0 0.0 0:00.02 pdflush (Bm39;49m
(Bm 149 root 20 -5 0 0 0 S 0.0 0.0 0:00.00 kswapd0 (Bm39;49m
(Bm 150 root 20 -5 0 0 0 S 0.0 0.0 0:00.00 aio/0 (Bm39;49m
(Bm 393 root 10 -5 0 0 0 S 0.0 0.0 0:00.00 kpsmoused (Bm39;49m6;1HK25;1H?12l?25h

Nemetode wrote:
> Processor (CPU): AMD Sempron™ Processor 3000+
> Total memory (RAM): 1.92 GB
> System: openSUSE 10.2 (i586)
>
> I hope this makes sense to someone…

wow, sure is a lot of garbage (control characters, etc) in that print
out…i’m gonna try to clean it up some:

> top - 18:46:06 up 9 min, 3 users, load average: 1.87, 1.80, 1.08
> Tasks: 123 total, 2 running, 120 sleeping, 0 stopped, 1 zombie
> Cpu(s): [too hard to clean…]
> Mem: 2010296k, 990820k used, 1019476k free, 22488k buffers
> Swap: 2104472k total, 0k used, 2104472k free, 591500k cached
<snip>

first, that one zombie program bothers me…especially since the
machine has only run NINE minutes…

do you know what it is that has crashed in the first nine minutes of
operation? (i’ve never seen one in my top)

second, i can see that in the above top snapshot none of your swap
space is used…however, that is as it should be when over half the
ram is unused…that is, it will be close to filling the ram before
it touches the swap space…

well, just now i found via google "If Linux runs out of memory and
swap space, it does not crash. It creates a swap file (or, at least,
finds some space on /) and adds it to the swap pool. This causes
major disk thrashing, but at least the system is still running. I
know; I used to have Ubuntu on an old iMac with 128 megs of RAM and
122 megs of swap, and both of those were full on startup :wink:

Unless you are doing some seriously intensive stuff, you do not need
more than 512 megs of swap." <http://www.linux.com/feature/121916>

now, whether or not that guy knows what he is talking about, i’m not
sure…so, let me ask: You said your swap is not being used and when
the ram fills up the server crashes—i wonder how you know exactly
what is causing the crash??

do you have info in a log file pointing to that assumption, or what??

do you know the time of the last crash, and have you looked through
the logs near that time to find error messages, etc??

if so, post those here…


DenverD (Linux Counter 282315) via NNTP, Thunderbird 2.0.0.14, KDE
3.5.7, SUSE Linux 10.3, 2.6.22.18-0.2-default #1 SMP i686 athlon

How do I locate this?

do you know what it is that has crashed in the first nine minutes of
operation? (i’ve never seen one in my top)

There are no apparent clues in the apache error or access logs apart from references to…

[Mon Aug 18 19:04:17 2008] [notice] Apache/2.2.3 (Linux/SUSE) configured – resuming normal operations

Which I assume is me rebooting the machine.

second, i can see that in the above top snapshot none of your swap
space is used…however, that is as it should be when over half the
ram is unused…that is, it will be close to filling the ram before
it touches the swap space…

well, just now i found via google "If Linux runs out of memory and
swap space, it does not crash. It creates a swap file (or, at least,
finds some space on /) and adds it to the swap pool. This causes
major disk thrashing, but at least the system is still running. I
know; I used to have Ubuntu on an old iMac with 128 megs of RAM and
122 megs of swap, and both of those were full on startup :wink:

Unless you are doing some seriously intensive stuff, you do not need
more than 512 megs of swap." <http://www.linux.com/feature/121916&gt;

now, whether or not that guy knows what he is talking about, i’m not
sure…so, let me ask: You said your swap is not being used and when
the ram fills up the server crashes—i wonder how you know exactly
what is causing the crash??

Haven’t a clue though I have noticed the screen is either blank (probably because of the power settings) or the picture is all fuzzy when it crashes…

{Dang! Where’s the UnderDog theme music when you need it?}

> > top - 18:46:06 up 9 min, 3 users, load average: 1.87, 1.80, 1.08
> > Tasks: 123 total, 2 running, 120 sleeping, 0 stopped, 1 zombie
> > Cpu(s): 24.5%us, 4.3%sy, 0.0%ni, 2.0%id, 68.8%wa, 0.3%hi, 0.1%si, 0.0%st
> > Mem: 2010296k, 990820k used, 1019476k free, 22488k buffers
> > Swap: 2104472k total, 0k used, 2104472k free, 591500k cached

Agree with Denver, all looks good here, system is still ‘coming up’ though,
as the load average is still high, and HAS been for a while (1.87,1.80,1.08)

Zombie not good… but not overly bad. We’ll ignore him for now, they don’t
eat much.

> second, i can see that in the above top snapshot none of your swap
> space is used…however, that is as it should be when over half the
> ram is unused…that is, it will be close to filling the ram before
> it touches the swap space…

Well, does depend on the program, since you CAN request to be swapped out…
most don’t do that and let the OS handle the details automatically.

But memory usage is fine, 990Meg in use, 22M used as ‘on-the-fly’ cache, not
much has been run yet, so cache buffers are still relatively empty.

Swap is untouched, that is expected with 2Gb of ram. (I’ve got 4Gb and it
takes a LOT of stuff to make it start swapping things)

> well, just now i found via google "If Linux runs out of memory and
> swap space, it does not crash. It creates a swap file (or, at least,
> finds some space on /) and adds it to the swap pool. This causes
> major disk thrashing, but at least the system is still running.

Uh, trying to be polite here… but NO.

Swap FILE creation CAN be performed by a watchful script, or an administrator
if they catch it in time… but linux will NEVER automatically create more
swap space. Swap FILES are like what Windows uses. It’s a file on the
storage medium, subject to the laws of the filesystem, with the inherent
delays and slowness. Don’t expect lots of speed if you create any ‘emergency
swap files’.

They CAN save your day though.

When linux ‘runs-out-of-memory’… the kernel hires a hitman and begins
shooting processes in the head. One shot, one kill… and it continues
this until it has enough memory to work with to try to do what it is stuck on
AT THE MOMENT.

This works… but the next process that initiates the hitman could be cause
your important program to be shot just as quickly. No, it’s not entirely
random, but it might as well be. It can zap your sshd server… no more
logins! your X server… no GUI! and so on. Try not to invoke the Hitman.

Linux prefers to use a swap PARTITION, since it is entirely controlled by the
swap daemon, and doesn’t have to bow to the whims of the filesystem.

> Unless you are doing some seriously intensive stuff, you do not need
> more than 512 megs of swap." <http://www.linux.com/feature/121916>

I suppose, but in this day and age of suspend, hibernate, sleep… you should
have at LEAST an equal sized swap partition as your ram… since the kernel
uses the swap partition to save the state of memory when it suspends or
hibernates. Again, the kernel is not allowed to arbitrarily use filesystem
space. So it uses the swap partition. (the swap daemon is really good
friends with the Kernel). (We don’t like General Failure though, he’s nosy.)

> so, let me ask: You said your swap is not being used and when
> the ram fills up the server crashes—i wonder how you know exactly
> what is causing the crash??

I doubt the ram is filling up, nor is the hitman being called. Something
else is causing the crash.

> do you know the time of the last crash, and have you looked through
> the logs near that time to find error messages, etc??

This would be good… and very helpful. The next time it crashes, if you
could post the contents of /var/log/messages along with the (approximate)
time it crashed. You can email it to me (address is ^^^^^, up there) if you
like, since it’ll be very long, and I’ll cut/paste the important bits.

> Haven’t a clue though I have noticed the screen is either blank or the
> picture is all fuzzy when it crashes…

Blank is probably the auto-screen blanker kicking in…

Fuzzy?!? Odd. Blurry?

Loni


L R Nix
lornix@lornix.com

hey Nemetode,

start paying attention to what Loni has to say…she IS the guru i’d
hoped would wonder by and take the time to try to help you…

she has asked you to do something…see her post and follow her
directions… (hint: the apache log is NOT where you are gonna find
the solution to this problem, and i zeroed in on the WRONG things
[ram and zombie])

you ARE in luck!


DenverD (Linux Counter 282315) via NNTP, Thunderbird 2.0.0.14, KDE
3.5.7, SUSE Linux 10.3, 2.6.22.18-0.2-default #1 SMP i686 athlon