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 money motivation

Opscomplete powered by makandra brand

Save money by migrating from AWS to our fully managed hosting in Germany.

  • Trusted by over 100 customers
  • Ready to use with Ruby, Node.js, PHP
  • Proactive management by operations experts
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)