Read more

find out which processes using swap

Claus-Theodor Riegg
January 15, 2016Software engineer at makandra GmbH

Wondering which processes are placed in your swap you can use this bash oneliner:

for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r
Illustration online protection

Rails professionals since 2007

Our laser focus on a single technology has made us a leader in this space. Need help?

  • We build a solid first version of your product
  • We train your development team
  • We rescue your project in trouble
Read more Show archive.org snapshot

You will see the swap usage of each process sorted by the highes amount of swap usage.

Please don't forget that swap usage of a process isn't an indicator for high memory usage of this process but for the frequency of access or activity of it. The kernel tries to avoid swapping pages which were recently accessed.

Also you should notice that the fact that memory pages allocated by a process are placed in swap does not mean that the pages are not in the main memory. Memory pages can be stored in the swap and in the main memory at the same time. This allows the system to release memory very quickly.

Posted by Claus-Theodor Riegg to makandra dev (2016-01-15 13:40)