Home > Linux > How to find what process are using Swap

How to find what process are using Swap

How to find what process are using Swap

/proc/meminfo – This file reports statistics about memory usage on the system. It is used by free to report the amount of free and used memory (both physical and swap) on the system as well as the shared memory and buffers used by the kernel. You can also use free, vmstat and other tools to find out the same information.

/proc/${PID}/smaps, /proc/${PID}/status, and /proc/${PID}/stat – Use these files to find information about memory, pages and swap used by each process using its PID.

top – To sort process as per swap page usage (SWAP = VIRT – RES) type capital O (option) followed by p (small p) and [Enter] key

Command to check Process using SWAP:
for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | grep kB | sort -k 2 -n -r | head -n 40


A way to change how th OS handle the swap is by changing the swapness
Default is 60
cat /proc/sys/vm/swappiness
To change so it only uses swap if SO is using around 90% of RAM available:
sysctl vm.swappiness=10

To forcefully erase swap, disable/enable it ( Be careful doing this, as you may make your system unstable, especially if its already low on RAM. )
swapoff -a
swapon -a

Reducing the default value of swappiness will probably improve overall performance for a typical Ubuntu desktop installation. A value of swappiness=10 is recommended


A good explanation why the default is 60:
http://unix.stackexchange.com/questions/88693/why-is-swappiness-set-to-60-by-default

Categories: Linux Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

VAMOVE *

*