# Weird swap usage under VMware



## spork (Apr 17, 2015)

I'm stumped by this since it's the first time I've noticed this behavior under VMware.  FreeBSD 8.4-p23, ESXi 5.0.0 (474610).

I started getting nagios alerts that swap usage on one of my `spamd`/`clamd` boxes was exceeding the threshold.  Not too alarming, both `spamd` and `clamd` are memory pigs.  But what I've been seeing is things like this:


```
Mem: 3623M Active, 526M Inact, 534M Wired, 194M Cache, 558M Buf, 3016M Free
Swap: 1024M Total, 174M Used, 850M Free, 16% Inuse
...
avail memory = 8240508928 (7858 MB)
```

This is a more minor example that I've captured.  Earlier that day I saw swap at 75%, still with over 3GB of RAM free.  I noticed that some of the `spamd` processes showed 0K resident, so I assume that's what's using my swap. 

The question is, why?

What happens if I don't take care of it is that swap reaches 100% and then the kernel starts killing things off:


```
swap_pager_getswapspace(16): failed
swap_pager_getswapspace(16): failed
pid 1267 (clamd), uid 106, was killed: out of swap space
```

At the time this happens, there are multiple GB of RAM free.

Is this the VMware tools doing something funny with RAM?  Docs on FreeBSD + VMware are really hard to come by and usually outdated.


----------



## spork (Apr 18, 2015)

OK, I think this is the balloon driver from vmware tools making the VM swap.

What I don't get is why it doesn't reliquish when swap is 100%...

Overview of all the RAM hackery in VMware: http://www.vmware.com/files/pdf/mem_mgmt_perf_vsphere5.pdf


----------

