This is a common issue in the new Linux kernels discussed on many forum threads. There is a long thread here about this problem.
In short the issue is that when you run out of memory “kswapd0” a kernel process than manages virtual memory will start moving “old memory entries” to swap. The “run out of memory” is a relative term that is in fact controlled by a kernel parameter. Usually in default Linux installations the “run out of memory” can mean that swapping will be done when 60% of the memory is full.
For some strange reasons this can go horribly wrong and will end up into a never ending loop of 100% CPU load which will freeze your system and make your system sound like an air-plane falling from the sky. At least that is the sound my office Dell laptop is making.
There are several solutions out there like “use less memory” or “buy more ram” that are ineffective as they sound and will just make you angry.
The most efficient solution so far is to tell kswapd0 to only move stuff to SWAP when you are completely out of RAM.
Edit /etc/sysctl.conf to make the change permanent
vm.swappiness = 0
Reload the configuration file to apply the settings without a reboot:
# sysctl -p
Where “0” is the percent of swappiness, or how much of the memory should be free
In case kswapd0 is still causing chaos (and you hear the air-plane falling) the following bash script can be run:
#!/bin/bash echo 1 > /proc/sys/vm/drop_caches
This will quickly invalidate all memory caches and make kswapd0 stop.
Contribute to this site maintenance !
This is a self hosted site, on own hardware and Internet connection. The old, down to earth way 🙂. If you think that you found something useful here please contribute. Choose the form below (default 1 EUR) or donate using Bitcoin (default 0.0001 BTC) using the QR code. Thank you !