Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can see swap's total, used, free etc. sizes from top command.
But I can't figure out which process uses swap, is it possible to find out swap memory by process?

I'm running CentOS 6.3.

share|improve this question
This has been answered at stackoverflow.com/questions/479953/… – Incognito Feb 7 '13 at 10:00
Is that for Linux, or some other Unix variant? The answer is likely to be very dependent on the variant. – Gilles Feb 7 '13 at 23:36
@Gilles I ask for CentOS 6.3 Thank you – trante Feb 8 '13 at 4:54
Somehow related: superuser.com/questions/300004/… – trante Feb 8 '13 at 15:22

You could use ps and some quick awk maths to gain the answer.

The command that you can use is this...

$ ps -eo rss,vsz,pid,cmd | awk '{print $2-$1,$0}' | sort -nr | head

The first column out the output should be the swap usage.

rss / resident set size

resident set size, the non-swapped physical memory that a task has used (inkiloBytes). (alias rssize, rsz).

vsz / virtual memory size

virtual memory size, the process in KiB (1024-byte units). Device mappings are currently excluded; this is subject to change.

Awk maths

If rss (Column 1) is the non swapped memory and vsz(Column 2) is the physical memory, then..

swap = vsz - rss 
share|improve this answer
No... the virtual memory size also considers the size of shared libraries, the executable itself, mapped memory areas (could be files mmap(2)-ed), ... – vonbrand Feb 7 '13 at 17:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.