VMware ESX admins have to pay attention to host swap file sizes because you can overcommit on memory. With Hyper-V, you can't overcommit on memory - for example, you can't take a host with 16gb of ram and start up 8 guests with 4gb of ram each. There's pros and cons to that approach. In a nutshell, though, you're right in saying it shouldn't need a host file - as long as you don't run anything on the host other than Hyper-V guests. If you remote desktop in and run things, or if you run third party backup or antivirus software on the host, you should set up a page file just to be safe. I've seen instances where people RDP into the host and run a backup software console written in Java, for example, and it needs gigs of memory in order to start & run a restore operation.
If info is swapped out to disc and later read back into memory, it will often be left allocated in the swap area until swap space runs low.
That means that if the same info needs to be swapped out again later and hasn't changed, the OS can just drop the pages from allocated RAM without needing to write anything to disc saving time.
Swap allocated to stuff that has been read back into memory will be freed either
- when the relevant pages are no longer needed at all (i.e. are freed by the application)
- when the relevant pages are changed (so the copy on disc is no longer up to date)
- the machine runs low on swap space so clears some things that are already in RAM to make room
Look in /proc/meminfo
for a line called "SwapCached". This entry counts pages that are found both in RAM and in swap partitions. For instance, picking a small VM at random, the /proc/meminfo
virtual file one of my VMs shows:
SwapTotal: 698816 kB
SwapFree: 624520 kB
SwapCached: 17232 kB
indicating that 74268K of swap space is allocated, but that 17232K worth of those pages are also currently mapped into RAM too (so could be deallocated from swap at a moment's notice if the space is needed by something else).
Also there will no doubt be pages sat there that was swapped out ages ago and have never been used again since. The kernel will not reload pages from swap just because there is some free RAM to read it back into as that free RAM might be better used for cache or buffers - pages written to swap are generally only reread when they are next needed.
If you want to clear out what is in swap, as long as you have enough free and/or freeable (i.e. free+cache+buffers (less those parts of the c+b counts that are not freeable RightThisInstant)), just turn it off and back on again with swapoff -a && swapon -a
.
Of course you could also have a memory leak somewhere too, but that is not the only explanation for the behaviour you are seeing.
Best Answer
I have just resolved my item with the same error. It is related to the windows page file and in my case it was configured to be automatically managed by windows.
In my situation Windows didn't think it wanted a higher swap space and wasn't taking out more space but it was at 0 remaining so zabbix was reporting the error. I have chosen to move to a custom page file size - just remember to hit set prior to saving as it won't always retain after a reboot.
System -> Advanced System Settings -> Advanced Tab -> Performance Settings -> Advanced Tab and changed to use a manual page file rather than the system allocated page file