Can be a generation 1 or generation 2 VM
The amount of memory added to a VM cannot exceed that which is available on the
host.
A VM cannot have more memory removed than is currently available within the
VM; that is, memory that is marked as in use by a process cannot be released. This
is different from Dynamic Memory, which could force a guest OS to page memory
to disk to release the required amount of memory to the balloon driver. This can be
thought of in a similar way as shrinking an NTFS partition—you can shrink a disk
down by only the amount of free space. To shrink a disk further, you would have to
delete data. To remove more memory from a VM than is currently available in the
VM, you would have to free up memory by stopping applications and services
Behind the scenes, when a Windows 10 or Windows Server 2016 VM starts that is not
configured with Dynamic Memory, the VM still utilizes the Dynamic Memory VSC,
which is started automatically, and all memory in the VM is configured as hot-
pluggable. This enables the memory to be removed in the future via the kernel mode
memory manager if required based on future configuration, as the kernel understands
that the memory is volatile and that access to it could change. Note that while memory
is discussed in terms of hot-add and remove, the memory is all synthetic and there is
no concept inside the VM of emulating addition and removal of sticks of memory. The
guest OS is fully enlightened.
The memory configuration can be altered for the running VM at any time through
Hyper-V Manager, PowerShell, and so on. This will result in the VM worker process
(VMWP) for the VM communicating to the API in the kernel of the VM via the
Dynamic Memory VSC, and the memory change will be implemented via the addition
or removal of memory pages. Inside the guest, the amount of memory currently
allocated will be seen, which is different from Dynamic Memory that would always
show the high watermark of memory assigned. When memory is removed, the
amount of memory visible inside the VM will decrease.
The ability to hot-remove memory from Windows 10 and Windows Server 2016 is also
utilized by Dynamic Memory, and ballooning is no longer used, as actually removing
the memory is more efficient and useful for the guest OS. Ballooning is still used by
Dynamic Memory for pre-Windows 10/2016 operating systems that do not support
hot-remove of memory.
When using this functionality, I have already mentioned that you cannot remove
more memory from a VM than is available and not being used, and you cannot add
more memory than is available in the host. If you attempt to remove more memory
from a VM than is available, then the maximum amount of memory that can be
removed will be taken from the VM, and you will receive an error message that the
memory change was only partially completed. If you attempt to add more memory
than is available, the same will occur; as much memory as is available will be added,
and an error message will indicate that the memory change was only partially