Linux: Find out which processes are swapped out

Posted . Visible to the public.

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.

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.

Thomas Eisenbarth
Last edit
Thomas Eisenbarth
License
Source code in this card is licensed under the MIT License.
Posted by Thomas Eisenbarth to makandra dev (2016-07-12 08:31)