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?
5 Answers
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.
- 5,116
- 17
- 15
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.
- 77,337
- 11
- 120
- 212
-
Pages are 4 KiB or 2 MiB, mostly — there're no real problems with even slicing of even 1234 MiB, are there? – poige Apr 08 '12 at 03:43
-
1@poige As best I know, yep, no issues... We'd really need someone who know SLAT (et alii) inside and out for a definitive answer. – Chris S Apr 09 '12 at 02:16
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."
- 10,982
- 2
- 34
- 29
-
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. – Goyuix Apr 07 '12 at 02:30
-
2I don't see how what you've said is at odds with my answer. Could you elaborate? – Andrew M. Apr 07 '12 at 02: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. – Goyuix Apr 08 '12 at 02: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. :) – Andrew M. Apr 08 '12 at 02: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
- 6,969
- 3
- 31
- 49
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.
- 23,938
- 4
- 35
- 58
-
http://serverfault.com/questions/377391/is-there-a-reason-to-give-a-vm-a-round-base-2-amount-2048mb-4096mb-etc-of-me#comment386454_377400 – poige Apr 08 '12 at 03: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. – TomTom Apr 09 '12 at 19:21