Linux: What is using all the Swap?

On Linux to discover which processes are using all the swap

  • run top
  • press ‘O’ (capital letter o)
  • then ‘p’
  • then ‘enter’

Processes should be sorted by their swap usage.As shown in the screen below the minilogd process is using all the swap space on this machine.

Linux Top Ordered by Swap UsageLooks like minilogd was gradually using up swap because someone had switched off syslog. So the logs had to go somewhere and minilog was looking after them (in memory then swap) until syslog would re-appear – which it didn’t. So to solve the issue we killed minilogd   (and lost the logs in memory/swap which we didn’t care too much about obviously) then started syslog and stability has been restored.

3 Responses to “Linux: What is using all the Swap?”

  1. Mike Trewartha

    The process listed above will show you the likely hood of something writing to swap, but not what is actually using swap.

    As you can see below, my swap space is being used:

    [root@server01 ~]# free
    total used free shared buffers cached
    Mem: 4043776 3168456 875320 0 177428 782104
    -/+ buffers/cache: 2208924 1834852
    Swap: 2097144 671132 1426012

    So you can go through your current PIDs to find out how much of that process is residing in swap with the following awk one liner.
    [root@server01 ~]# awk ‘/^Swap:/ { SWAP+=$2 } END { print SWAP” kB” }’ /proc/2659/smaps
    411308 kB

    where 2659 is the PID of the process you’re checking.

    Reference: http://planet.mysql.com/entry/?id=32809

    Reply

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>