Have you ever logged in to a server, ran `free`, seen that a bit of swap is used and wondered what’s in there? It’s usually not very indicative of anything, or even overly helpful knowing what’s in there, mostly it’s a curiosity thing.
Either way, starting from kernel 2.6.16, we can find out using smaps which can be found in the proc filesystem. I’ve written a simple bash script which prints out all running processes and their swap usage.It’s quick and dirty, but does the job and can easily be modified to work on any info exposed in /proc/$PID/smapsIf I find the time and inspiration, I might tidy it up and extend it a bit to cover some more alternatives. The output is in kilobytes.