Monday, 26 November 2018

swap - Unnecessary Swapping in Linux


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.



Answer



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


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...