About
This little utility for Linux shows the amount of swapped memory for running processes.
Contrary to popular belief this is actually not that easy, and tools like
top
either don't do this at all, or completely wrong; see
this discussion on StackOverflow for some background.
After finding some of the proposed scripts unacceptably inefficient, I decided to write my own in C++.
Requirements
- Compiler with C++14 support
- Linux :)
Installation
- Type "make" & copy the executable wherever you want.
- If you encounter any problems then please fix them and send a pull request. :)
Gentoo users can find an ebuild in my overlay.
Usage
$./swapusage -h
Usage: swapusage [pid]
$./swapusage
====================================
Swap kB PID Name
====================================
976 5531 pulseaudio
292 2738 zsh
64 5239 gam_server
------------------------------------
1332 kB total.
$./swapusage 5531
====================================
Swap kB PID Name
====================================
976 5531 pulseaudio
More information
While swapusage is a good first step towards analyzing a swap (and memory) situation, you might find that you need much more detailed analysis capabilities. In that case you could look at smem.