0

On a small VPS of mine, I have enough free memory for the things that are running there (as in the log below), but every once in a while, when I run free -m, I see all the swap is taken up.

What could it mean? Is it something I should be worried about or is it just swap that was not freed from a previous spike or something?

             total       used       free     shared    buffers     cached
Mem:           256        225         30          0          5         46
-/+ buffers/cache:        173         83
Swap:          511        511          0
John Gardeniers
  • 27,262
  • 12
  • 53
  • 108
deusex
  • 1

2 Answers2

0

Your system use all swap after memory spike. Use ps(tor or htop) to find process that use a memory.

ooshro
  • 10,874
  • 1
  • 31
  • 31
0

When you see the output of "free -m" as quoted above, the memory is still in use, so you are in a middle of a "memory spike". Swap space gets immediately freed after the process(es) die, that used it.

Unfortunately, it is hard to find out with "ps", which of your processes are eating the swap space. A first bet is any of the processes, that also uses a lot of non-swapped-out memory. If you can easily restart them and can live with the service being interrupted for a few seconds, just "kill" those suspects and see, whether swap use goes down.

Kai Petzke
  • 378
  • 1
  • 3
  • 10
  • The fact that there is a quantity of free and cached memory suggests that much of what is in swap is not being frequently used, vmstat would probably show a low number of swap blocks in/out. top(1) can be sorted by memory usage and will likely show who the offenders are so that they can be restarted. – mtinberg Jun 29 '11 at 18:13