[CentOS] What is eating up Swap

Sat Dec 14 13:45:06 UTC 2013
Stephen Harris <lists at spuddy.org>

> # free -m
>              total       used       free     shared    buffers     cached
> Mem:         32081      31784        296          0        206       2635
> -/+ buffers/cache:      28943       3137
> Swap:        16111       3220      12891

> free memory without need of swapping?

Not really.  The values at the time of that snapshot show that you've
just exceeded memory (swap used (3220) > free (3137)).  However what
you can't see, from this, is other periods of peak load.  Maybe you
have overnight processing going on that causes extra memory requirements
at that time?

You might be able to tell, from "sar" output or similar. 

Maybe you had an extra VM running temporarily that has since been shut
down?

There could be many reasons for a temporary increase in memory usage.

Once a page has been swapped out then the kernel won't normally swap
it back in unless it's needed again.  Efficiency; non-requested pages
can happily stay on swap and leave RAM free for real activity :-)

Having pages in swap is not indicative of a problem; what's more
important is the level of swap _activity_.  See "vmstat" output, for
example, to determine how much swap activity is occuring.  If that's
zero then you're not throwing new pages out to swap.

-- 

rgds
Stephen