Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

On a linux server (Ubuntu Lucid), my used swap keeps growing by the hour on a server, and I'm having a hard time identifying which process is growing in swap.

What tool can I use to monitor this?

share|improve this question
up vote 6 down vote accepted

The usual way I do this is to let the system run until the swap utilization is evidently higher than it "should" be. Once you can see the problem run top, sort by Virtual Memory Size (sometimes just called Size, or VIRT on Linux -- The guy with the largest difference between VM Size and Resident size (RES) is usually your culprit.

The best way to know for sure is to make sure it's safe and then kill the process - If your swap suddenly frees up you found your leak.

share|improve this answer
Looking at the diff between resident memory and VM size is a good hint. Thanks. – ℝaphink May 17 '11 at 15:18
It's about 90% reliable -- I've found very few programs that allocate gobs of RAM and intentionally let it go stale enough that it gets swapped out :) – voretaq7 May 17 '11 at 15:19
As a note, < and > can be used to select the column to sort by. – ℝaphink May 18 '11 at 7:59
Didn't know about < and > (Apparently doesn't work on FreeBSD 8's top though - you have to use o to set the sort order there) – voretaq7 May 18 '11 at 15:15

Have you tried running top and pressing M to sort all processes by memory usage?

share|improve this answer

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.