Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I know which process is using swap?

Tags:

linux

memory

swap

There is lots of memory avaiable(about 4G) but swap is used(200+M) in my fedora box.

I wonder which process is using swap. How can I know it.

ps and top only show the memory usage.

Thanks in advance.

like image 929
Wiky L Avatar asked May 27 '15 11:05

Wiky L


People also ask

What is using my swap space Linux?

Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM.


1 Answers

Improving the cyberciti.biz command to show a more concise answer:

(echo "COMM PID SWAP"; for file in /proc/*/status ; do awk '/^Pid|VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | grep kB | grep -wv "0 kB" | sort -k 3 -n -r) | column -t

An example output:

COMM             PID    SWAP  
dockerd          662    2736  kB
skypeforlinux    26865  1320  kB
NetworkManager   303    1112  kB
slim             392    1028  kB
redis-server     350    204   kB
like image 53
adrianlzt Avatar answered Oct 22 '22 21:10

adrianlzt