Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Hyper-V "Not enough memory in the system to start the virtual machine": how to find the headroom and fix it

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

A Hyper-V VM that fails to start with "Not enough memory in the system to start the virtual machine", or with "Could not initialize memory: Ran out of memory (0x8007000E)", is asking for more memory than the host can currently give it. Microsoft's Dynamic Memory page lists both messages together and says to check the Performance Monitor counter Hyper-V Dynamic Memory Balancer, Available Memory. If the VM's startup memory is larger than that figure, lower the startup memory or free memory from other VMs; adding physical RAM is the other route.

What the error means

Hyper-V does not hand every byte of host RAM to VMs. Microsoft says "Hyper-V running on Windows Server automatically calculates an amount of memory to reserve for exclusive use by the management host operating system", and that in a failover cluster it also reserves enough to run the cluster services. Its Memory Performance page, in the sentence written for Windows Server 2016, adds that Hyper-V "monitors the runtime health of the root partition's management operating system to determine how much memory can safely be allocated to child partitions".

At start, a VM needs its startup memory in full. Microsoft defines startup memory as "the minimum amount of memory that a virtual machine can have" under Dynamic Memory, and says Smart Paging, the disk-backed extra memory, is not used when a VM is started from an off state; it applies to restarts only. So a VM whose minimum is below its startup memory still needs the whole startup figure on a cold start.

The same shortage appears during live migration. Microsoft's live migration page lists "Failed to create partition: Insufficient system resources exist to complete the requested service. (0x800705AA)", for which it says to reduce the memory assigned to the VM or turn off some VMs on the destination, and "could not initialize memory: Ran out of memory (0x8007000E)", for which it says to check the available memory on the destination host.

Likely causes

Cause What you see How to confirm
VM's startup memory is larger than the host's available memory The start fails at once with one of the two messages The Available Memory counter is lower than the VM's startup memory
Other running VMs hold most of the memory Starts fail only while other VMs run The Available Memory counter is low while other VMs run (configured memory of the running VMs is only a guide)
Dynamic Memory is off, so the full static amount is needed A large fixed amount is assigned Get-VMMemory shows Dynamic Memory disabled and a large startup figure
Failover cluster services keep a further reserve Less memory is available than a plain host of the same size The host is a cluster node
Destination host is short during a live migration 0x800705AA or 0x8007000E in a migration failure Hyper-V-Worker events on the destination

Prove the cause before changing anything

All of these only read.

1. Read what the host can give VMs. On the host, open Performance Monitor and add the counter Hyper-V Dynamic Memory Balancer, Available Memory. Microsoft's FAQ names this counter as the way to see "the current amount of memory available to virtual machines". A good result for this fault is a figure lower than the VM's startup memory.

2. Read the VM's memory settings.

Get-VMMemory -VMName web01 | Format-List *

Microsoft's reference describes the cmdlet as one that "Gets the memory of a virtual machine or snapshot". Note whether Dynamic Memory is enabled and the startup, minimum and maximum values. The Set-VMMemory page lists the parameters StartupBytes, MinimumBytes and MaximumBytes, which gives the property names to look for.

3. List the VMs and their states.

Get-VM

For each VM whose state is Running, run the Get-VMMemory line above with its name. That shows each VM's configured startup, minimum and maximum values, not what a Dynamic Memory VM holds at this moment, so the sum is only a guide; the counter in step 1 is the figure that decides.

4. Read the migration events if the failure came during a move. On the destination host:

Get-WinEvent -LogName Microsoft-Windows-Hyper-V-Worker-Admin -MaxEvents 50

The live migration page names this log; look for the 0x800705AA text above.

Fix

Microsoft's Dynamic Memory page sets out the rules: the startup value "needs to be high enough to allow the guest operating system to start, but should be as low as possible", minimum memory can be set up to the startup value, and maximum memory from the startup value upward. Any new startup value must keep minimum at or below startup and maximum at or above it.

Lower the startup memory of the VM that will not start

This is for a VM that is Off, which web01 is after a failed start.

First save the current memory settings:

Get-VMMemory -VMName web01 | Format-List * > vmmemory-before-web01.txt

Risk: the next commands lower web01's startup memory and then start it. A guest given less memory than its workload needs can start slowly, page heavily or fail its applications, and the start needs the whole startup figure to be free on the host.

First read vmmemory-before-web01.txt. If Dynamic Memory is on and the saved minimum memory is above the new startup value, expect the command to be refused, because Microsoft's Dynamic Memory page sets minimum memory at most equal to the startup value; in that case add -MinimumBytes with a value at or below the new startup value to the same command (and restore it in the undo).

Set a startup figure that fits the headroom from the counter, then start the VM. -StartupBytes is the parameter Microsoft documents for the initial memory with Dynamic Memory on, and for the total with it off. The value below is an example only:

Set-VMMemory -VMName web01 -StartupBytes 4GB
Start-VM -Name web01

To undo it: set startup memory (and minimum memory, if you changed it) back to the figures in the saved file, then read them back. Use the values exactly as the saved file shows them. The block ends with web01 off; start it again with Start-VM -Name web01 if it was running before.

Risk: the next commands power web01 off without shutting the guest down, so anything the guest has not written to disk is lost.

Stop-VM -Name web01 -TurnOff
Set-VMMemory -VMName web01 -StartupBytes <startup value from the saved file>
Get-VMMemory -VMName web01 | Format-List *

Free memory from other VMs, or add RAM

For the 0x800705AA error Microsoft's live migration page gives "turn off some virtual machines" on the destination as the other way to make room. Which VM can be turned off is a service decision for the people who use them, so it is not scripted here. Adding physical RAM to the host raises the figure the counter reports; plan it as hardware work for that host.

Example (illustrative): hv01 has 64 GB of RAM. Three running VMs hold 16 GB, 24 GB and 16 GB, which is 56 GB (16 + 24 + 16). web01 is set to 8 GB of startup memory, and 56 + 8 = 64 GB would use every gigabyte of physical RAM and leave nothing for the host's own reserve. web01 fails with "Not enough memory in the system to start the virtual machine". The Available Memory counter reads below web01's 8 GB startup figure. The engineer saves vmmemory-before-web01.txt, sets web01's startup memory to 4 GB (56 + 4 = 60 GB, leaving 4 GB of RAM unassigned) and starts it. It starts.

Confirm the fix

  1. Get-VM shows web01 as Running.
  2. The Available Memory counter still reads above zero, so the host has room.
  3. Get-VMMemory -VMName web01 | Format-List * matches the value you set.
  4. Inside the guest, the workload behaves normally. A startup value that is too low shows up as slow starts or paging in the guest.

What to watch afterwards

  • Keep the total of all VMs' startup and fixed memory below the host's RAM minus its reserve, with room to restart VMs, since a restart can need more memory than the steady state.
  • Microsoft recommends that you let the system manage the page file size on a Hyper-V host.
  • After changing a VM's memory, check the guest's own page file and application settings.
  • In a cluster, plan memory so the remaining nodes can hold the VMs of a failed node.

Risks and limits

  • These commands have not been run or lab-tested.
  • Microsoft's pages do not give a formula for the host's reserve; it is calculated by Hyper-V, so use the counter rather than a rule of thumb.
  • Lowering startup memory moves the problem into the guest if the workload needs the memory.
  • Dynamic Memory suits some guests and not others; check the application vendor's guidance before enabling it.

Sources