Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It seems that sometimes, my computer will start swapping unnecessarily (memory usuage is ~25%), and I can't figure out why.

It seems to happen most often when running Perl scripts, but these aren't intensive scripts, and I can't find any thing saying that Perl can only see a certain amount of memory. The swap usage persists after the scripts finish, and even after closing Firefox, Banshee, etc. Restarting X will sometimes solve the problem, but other times, a full restart is required.

This becomes a big problem for me because as soon as whatever-it-is starts swapping, everything else seems to as well. Basic things like closing program or switching viewpoints take longer and longer. If left unchecked, this swap usage will eventually force my computer into indefinite thrashing, unable to even respond to keystrokes!

I'm running Ubuntu 9.04, 2.6.28-15 kernel, I've got 4GB of RAM, and am usually sitting at ~25% usage.

I've also tried lowering the "swappiness," with no luck.

share|improve this question
How are you monitoring the swapping - vmstat? Can you check what happens if you use swapoff to disable swap space? – nagul Aug 26 '09 at 22:30
Please post the output of free -m and cat /proc/meminfo. It really sounds like you're far above 25% usage. – derobert Aug 27 '09 at 5:28
I haven't been able to reproduce this since asking the question. I will update when it happens again. – Ryan Fox Aug 27 '09 at 23:14
up vote 3 down vote accepted

My suggestion is setting your swappiness to 0.

Setting your swappiness to a "lower number" may reduce the "frequency" of using swap, but setting it to 0 will force the kernel down a different code path, forcing all memory allocation to first use up all available memory and cache before using swap space.

You can set swappiness to zero by issuing the following:

echo 0 > /proc/sys/vm/swappiness

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.