Read more

Linux: Find out which processes are swapped out

Thomas Eisenbarth
July 12, 2016Software engineer at makandra GmbH

Processes in Linux might be put into Swap ("virtual memory") occasionally.
Even parts of a single process might be removed from memory and put into Swap.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

In order to find out which processes remain within Swap, run this:

sudo grep VmSwap /proc/*/status | egrep -v "0 kB"

Keep in mind Swap is not evil by definition. Some bytes per process beeing put to Swap will not have that much of performance influence.

If you want the Linux virtual memory manager (which is responsible for the decision if and which processes are moved to Swap) to be more or less agressive, tune the vm.swappiness kernel parameter via sysctl:

sudo sysctl vm.swappiness 0 # Linux will only use swap if *no* other memory is available

sudo sysctl vm.swappiness 1 # Linux will try to avoid swap whenever possible

The default value of the swappiness parameter is 60.

Posted by Thomas Eisenbarth to makandra dev (2016-07-12 10:31)