The title pretty much says it all, is there any advantage to giving a VM 2048MB of memory instead of rounding to base-10 and doing 2000MB?
The physical memory in the server is a multiple of a power of two, so it will slice evenly if you use other multiples. There may be some incredibly minor improvements with SLAT and such if they're properly aligned too. Otherwise no.
Hyper-V internally allocates memory in 2MB chunks. The hypervisor itself will use 2MB page table entries for efficiency, if possible, if your processor supports Second-Level Address Translation (SLAT.) This will be possible for pretty much any VM with Dynamic Memory turned off.
Other than that, no it doesn't matter.
Just to clarify what the other answers have said; the limit that's being defined here is basically for your virtual machine's software, not the guest. That is, when your guest OS requests a page of memory, its doing so in defined increments (i.e., 4KB). So if you defined the virtual machine to have 4097KB of RAM, and your host VM was using a 4KB page size, then it would likely grant a total of 4100KB of RAM to the virtual machine.
If the guest OS, however, were to use a 1KB page size, and your host OS used a 4KB page size, then the host OS would essentially grant 4KB of space of which only 1KB will be used--but that's out of all the chunks of memory. So you will never really be wasting any discernible amount of space.
To note, alignment between the host OS and guest OS is not a factor here except for that last "off bits."
This isn't true under certain circumstances: For example the VM software can reserve the entire requested RAM amount (plus whatever it needs for the video card and other misc. needs) or when using nested paging/extended page tables hardware support - the guest effectively manages the physical pages of memory using the CPU hardware. Also, reserving 4097KB of memory would most likely allocate 4100KB of physical RAM, though only 4097KB would actually be addressable by the guest operating system.– GoyuixApr 7, 2012 at 2:30
2I don't see how what you've said is at odds with my answer. Could you elaborate? Apr 7, 2012 at 2:42
That may have been your intent, however in reading your answer as "you would essentially never be able to use that extra 1KB" -- I tried clarifying that the guest OS could (in theory) use that RAM even though 3/4 of the physical page would likely be untouched. Your answer does not read as very clear to me. I also tried to provide some keywords/technologies that would have an impact on those decisions. Page alignment issues are just one part of the trade offs that would need to be considered and I felt the answer could be improved by mentioning relevant impacts to it specifically.– GoyuixApr 8, 2012 at 2:37
Ah, I see where I went wrong. That's actually how I was envisioning it, but I must have gotten rid of it in my various revisions. I've updated it to clarify that point. :) Apr 8, 2012 at 2:59
I suspect its a matter of tradition, and aligning it with how physical systems are built. Physical systems have memory in base 2 amounts (and least with every x86 ever made, this is true), and chances are some if not many OSes would expect this in managing memory.
In short, it really is because a virtual machine reflects a real machine, rather than a hypothetical one. Not a very technical answer, but I think that is the real one
Not really. Hyper-v dynamic memory will only allocate what the system uses anyway. The amount you assign is the startup value. If you are not using dynamic memory the only advantage I can see is to better align the physical memory to virtual.
serverfault.com/questions/377391/…– poigeApr 8, 2012 at 3:45
-1. See, Hyper-V has no dynamic memory IF NONE IS CONFIGURED. And guess what - sometiems it make sense not to use that (alolocation takes time, so a database server wants it all iimediately, for example). As such, the generic answer is not relevant and - actually - not what was asked at all.– TomTomApr 9, 2012 at 19:21