Windows – ESXi granting windows guest ALL of its assigned memory

vmware-esxivmware-vspherewindowswindows-server-2012

I've seen this a few times now and I don't understand what is happening

I assigned a windows guest 200 gigs of RAM- NOT reserved.

Looking at the guest right now the OS shows its only using about 2 gigs of RAM.

ESXi though, has allocated it the full 200 gigs of RAM (the host is now generating low memory alerts)! Windows is only using 2 gigs so why has ESXi granted the VM all 200 gigs?

Is this a case of Windows demanding more RAM then it is using? How can I troubleshoot this?

Best Answer

Quoting from here:

A host allocates the memory specified by the Limit parameter to each
virtual machine, **unless memory is overcommitted** (emphasis mine).
ESXi never allocates more memory to a virtual machine than its specified
physical memory size.

[...]

When memory is overcommitted, each virtual machine is allocated an
amount of memory somewhere between what is specified by Reservation
and what is specified by Limit. The amount of memory granted to a
virtual machine above its reservation usually varies with the current
memory load.

So, unless the host needs more memory than what it actually has in order to fulfill the requirements of all VMs running on it, it will happily allocate to each VM all the memory it requests, even if it's not reserved; however, if and when overcommitment happens, the host will reclaim some of this memory in order to free it up for other VMs; in this scenario, as much memory will be reclaimed as the load demands, until it reaches the reserved amound for each VM. If, even after bringing each VM's allocated RAM down to its reserved amount, the memory requirements for starting another VM can not be fulfilled, it will not be started. Of course, if a VM's memory is brought down to its reserved amount and this isn't enough for the VM to operate properly, slugginesh and/or errors will ensue.


Let's assume you have 300 GB of RAM and have two VMs, of which each one has a limit of 200 GBs. When you start the first one, it will get the full 200 GBs. When you start the second one, the host will try to fulfill both requests, but since it doesn't have 400 GBs available, it will setle down to giving 150 GBs to each VM. Then, depending on the actual load of those VMs, memory could be furtherly moved around: if a VM tries to use 180 GBs while the other one is sitting at 20 GBs, the host will move 30 additional GBs from the second VM to the first one.

Of course, if both VMs tries to use all 200 GBs, the host will start swapping like crazy; that's your clue to add more RAM or move one VM somewhere else.