Memory allocation

Hello!

My host PC (RAM = 16 Gb) hosts two VMs, each has been allocated 6Gb of Ram. After starting VM1 host's Task Manager shows there's ~8Gb available:

Nevertheless, when I'm trying to run VM2 I get this error:

Would anybody please point me to the document stating how much memory should be available on the host after all VMs have been started?

Thank you in advance,

Michael

April 27th, 2015 9:23am

try this one in PowerShell

"Hpyer-V-Hostname"|%{"Memory Available on "+$_+" : "+("{0:N2}"-f(((get-vmhost$_).MemoryCapacity /1GB) -((get-vm-computername$_|measureMemoryAssigned-sum).sum /1GB))).ToString() +" GB"}

With the Task Manager you look into the Parent Patition

For better planning use this

  • Guest with 2 GB Memory = +40 MB Overhead
  • Guest with 4 GB Memory = +56 MB Overhead
  • Guest with 8 GB Memory = +88 MB Overhead

Free Windows Admin Tool Kit Click here and download it now
April 27th, 2015 1:04pm

"Hpyer-V-Hostname"|%{"Memory Available on "+$_+" : "+("{0:N2}"-f(((get-vmhost$_).MemoryCapacity /1GB) -((get-vm-computername$_|measureMemoryAssigned-sum).sum /1GB))).ToString() +" GB"}":

"For better planning use this

  • Guest with 2 GB Memory = +40 MB Overhead
  • Guest with 4 GB Memory = +56 MB Overhead
  • Guest with 8 GB Memory = +88 MB Overhead" -

If a Guest with 8Gb RAM has only 88 MB overhead why I can't start a VM with 6 Gb Ram while having a margin of more than 2 Gb (8.1Gb - 6Gb)?

April 27th, 2015 1:19pm

Hi Michael,

consider to use dynamic memory on your VMs.
Doing so, I'm running a whole test domain on my laptop which has 12GB memory.

The machines will only get what they need and in idle times you'll have more memory available on your PC.

Best Regards,
Jens

Free Windows Admin Tool Kit Click here and download it now
April 27th, 2015 2:41pm

You have some excellent answers here.

But to add - There are processes that run within the management OS that consume RAM.  And the overall memory use of the management OS is not VMs only.

If you run an application and that application consumes 2GB of RAM - then Hyper-V is going to consider this RAM 'allocated' and it will not try and steal it away just to start your VM.

Usually an easy way to clear this type of memory use (especially when it becomes a block) is to logout and then log back in - this forces memory clean up within your user session and usually resolves these types of situations.

This is especially the case if you leave the Hyper-V Management console open and you connect to your Hyper-V Server using RDP.  The RAM is not free'd on disconnect and reconnect and keeps consuming more.  Only a logout cleans it up.

April 27th, 2015 3:00pm

Part of what you're suffering from a choice Microsoft made in how to display memory usage. If you hover over the middle part of the display meter, you'll get a tooltip that shows how much memory is in "Standby". The Windows memory manager might free this up for applications under certain conditions, but Hyper-V won't consider it as available when it's trying to determine if it should turn on a VM. The right-most section of the meter shows much is actually free. I can only guess by looking at your meter, but I assume that knocks you down to more like 7 GB free for Hyper-V usage. The second barrier is that Hyper-V is not going to zero out the host's memory to turn on a guest. The host reserve is now auto-calculated and not easy to work with anymore, but anecdotal evidence would suggest somewhere in the vicinity of 1GB of memory on the low side. I suspect that the actual free memory minus the host reserve is below the 6196 megabytes your VM is configured to use, which would explain why you're seeing what you're seeing.

Your choices are to reduce guest memory allocation or implement Dynamic Memory. If memory reduction is an option, you're probably within a few hundred megabytes.

Free Windows Admin Tool Kit Click here and download it now
April 27th, 2015 3:01pm

To add to Eric's answer here - the host defaults to 2Gb for itself.

You can get the host to kick out some of the virtual memory held by host OS processes by attempting to start your VM 3 times in a row.  (this is an old feature).

It does not work in all cases, but can get you past blocks when you are right on the edge of being able to start a VM and there is virtual memory to recover.

April 27th, 2015 3:33pm

Hello,

Thank you all for your replies!

"To add to Eric's answer here - the host defaults to 2Gb for itself." - that's why I'm asking this question: the total Host's RAM = 16Gb, I have 2 VMs with 6Gb each, so 16 - 2*6 = 4GB (~3.5Gb) remains unallocated...

I have exactly the same HOST2 machine with two VMs with RAM=6Gb and they work perfect. Today I restarted Host1 and Host2 (it is Host2 which can't run the second VM) and the issue has gone - both VMs can run simulteniously:


Seems it was definitely a matter of "a few hundred megabytes".

The last question regarding "the host defaults to 2Gb for itself": (please see the next reply):

Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 4:45am

-the words "the host defaults to 2Gb for itself" mean that the host must have at least 2GB NOT including  the RAM required for loading OS or including OS? In other words, must a host have 2GB after the OS and all VMs are loaded or I just can always allocate to host itself no more than 2Gb?

Regards,

Michael

April 28th, 2015 4:56am

There is a hidden setting called "memory reserve" - the host will keep giving of its RAM until it hits this low water mark setting.

At the same time, as was mentioned, programs running on the host impact this calculation as they create a memory demand of the host.  When a program takes memory to run programs (or programs running on the host consume RAM) they increase the amount of RAM that the host has to retain for itself.

It does not change the memory reserve - it just means that the host thinks it is actively using more than the memory reserve and makes sure that it can keep functioning. 

This is what was cleaned up by the act of rebooting.  Simply logging out and back in would have accomplished the same thing without impacting running VMs.

Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 9:12am

I have a very similar situation on one of my lab systems. If I've been on the console and working for any amount of time, there is almost no chance of starting all the VMs. If I log off and issue Start-VM from my desktop, there is about a 30% chance they'll all start. If I reboot the host and RDP to the console and do nothing else but try to start them, there's about a 50% chance they'll all start. If I reboot the host and issue the Start-VM remotely without ever logging in, there's about an 80% chance they'll all start. I haven't invested any time in this problem because lab, but my assumption is that if I logged off and waited a few minutes, the 80% metric would be a fairly consistent norm. But the point is, when you get down into the last few megabytes, there will be wiggle room and some degree of inconsistent behavior.
April 28th, 2015 9:30am

"but my assumption is that if I logged off and waited a few minutes, the 80% metric would be a fairly consistent norm." - I suppose it can help in case a host has at least as many free RAM as memory reserve, am I right?

"There is a hidden setting called "memory reserve" - and this setting is set to 2Gb?

Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 10:49am

There is a registry key called memory reserve.

We used to tweak it.  MSFT now recommends that it not be touched any longer because the host handles memory more efficiently.

However, as we have outlined, committed virtual memory due to running programs / consoles, RDP sessions, etc. toss this all out.  As they take up RAM that the system does not reclaim when a VM is attempted to be started.

April 28th, 2015 10:54am

"There is a registry key called memory reserve" - Is it = 2Gb?
Free Windows Admin Tool Kit Click here and download it now
April 29th, 2015 3:29am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics