Linux – using the swap space

linux-kernelswap

On a Debian Linux 3.16 machine, I have 244 MB of swap space used:

# free -h
             total       used       free     shared    buffers     cached
Mem:           94G        36G        57G       1.9G       3.8G        11G
-/+ buffers/cache:        20G        73G
Swap:         487M       244M       243M

Looking at this, I cannot find 244 MB used.

# for file in /proc/*/status ; do grep VmSwap $file; done | sort -nk 2 | tail
VmSwap:        0 kB
VmSwap:        0 kB
VmSwap:        0 kB
VmSwap:        0 kB
VmSwap:        0 kB
VmSwap:        0 kB
VmSwap:        4 kB
VmSwap:       12 kB
VmSwap:       16 kB
VmSwap:       36 kB

And I only have 34 MB of SwapCached:

# grep -i swap /proc/meminfo
SwapCached:        34584 kB
SwapTotal:        499708 kB
SwapFree:         249388 kB

Kernel doc says about this:

SwapCached: Memory that once was swapped
out, is swapped back in but still also is in the swapfile (if memory
is needed it doesn't need to be swapped out AGAIN because it is
already in the swapfile. This saves I/O)

How can I know which process is using my swap space on my Linux system? More precisely: Where are consumed each of those 244 MB of swap?

Best Answer

How can I know which process is using my swap space on my Linux system?

Swap space is not necessarily used by specific processes.

More precisely: Where are consumed each of those 244 MB of swap?

Files stored on tmpfs based file systems might be using them (tmpfs first uses RAM as back-end but, not to waste RAM, can paginate out to the swap area blocks that are not actively used).

Check the output of :

df -ht tmpfs
Related Question