none
Memory allocation RRS feed

  • Question

  • 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

    Monday, April 27, 2015 9:23 AM

Answers

  • Hi Sir,

    >>There is a registry key called memory reserve" - Is it = 2Gb?

    I tested in my lab , it can be less than 2GB , it is controlled by Host OS dynamically .

    In addition , it seems that it is more related to cached memory :

    You may try to use this formula : (Available - Cached) .

    Best Regards,

    Elton Ji


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com .

    • Proposed as answer by Elton_JiModerator Monday, May 11, 2015 11:24 PM
    • Marked as answer by MF47 Tuesday, May 12, 2015 8:23 AM
    Monday, May 11, 2015 1:45 AM
    Moderator

All replies

  • 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

    Monday, April 27, 2015 1:04 PM
  • "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)?

    Monday, April 27, 2015 1:19 PM
  • 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


    jensit.wordpress.com

    Monday, April 27, 2015 2:41 PM
  • 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.


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.

    Monday, April 27, 2015 3:00 PM
    Moderator
  • 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.


    Eric Siron
    Altaro Hyper-V Blog
    I am an independent blog contributor, not an Altaro employee. I am solely responsible for the content of my posts.

    Monday, April 27, 2015 3:01 PM
  • 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.


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.

    Monday, April 27, 2015 3:33 PM
    Moderator
  • 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):

    Tuesday, April 28, 2015 8:43 AM
  • -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

    Tuesday, April 28, 2015 8:54 AM
  • 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.


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.

    Tuesday, April 28, 2015 1:10 PM
    Moderator
  • 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.

    Eric Siron
    Altaro Hyper-V Blog
    I am an independent blog contributor, not an Altaro employee. I am solely responsible for the content of my posts.

    Tuesday, April 28, 2015 1:27 PM
  • "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?

    Tuesday, April 28, 2015 2:46 PM
  • 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.


    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.

    Tuesday, April 28, 2015 2:52 PM
    Moderator
  • "There is a registry key called memory reserve" - Is it = 2Gb?
    Wednesday, April 29, 2015 7:26 AM
  • Hi Sir,

    >>There is a registry key called memory reserve" - Is it = 2Gb?

    I tested in my lab , it can be less than 2GB , it is controlled by Host OS dynamically .

    In addition , it seems that it is more related to cached memory :

    You may try to use this formula : (Available - Cached) .

    Best Regards,

    Elton Ji


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com .

    • Proposed as answer by Elton_JiModerator Monday, May 11, 2015 11:24 PM
    • Marked as answer by MF47 Tuesday, May 12, 2015 8:23 AM
    Monday, May 11, 2015 1:45 AM
    Moderator
  • Hi Elton_Ji,

    "You may try to use this formula : (Available - Cached) ." - I get it now -thank you very much!

    Regards,

    Michael

    Tuesday, May 12, 2015 8:23 AM