Driver Locked Memory on Hyper-V Guests

When monitoring the available memory on your Hyper-V guests, you may come across a curious issue where the available memory on the VM seems low given the memory usage of the processes currently running.  For example, the guest may have 12GB of memory with running processing consuming less than 2GB; yet, Task Manger shows only 1GB of available memory!

Task Manager Guest Memory Usage

Diagnosing the apparent problem further with a tool like RAMMap from Sysinternals, shows a huge chunk of memory being "used" as Driver Locked.

What is driver locked memory, and is this a problem?
Driver locked memory is when a kernel-mode driver prevents memory pages from being swapped to the page file.  It is through this mechanism that Hyper-V varies the amount of available memory to a guest when Dynamic Memory is enabled. In the case above, the Hyper-V Manager may show the guest only using about 50% of its maximum allocated memory with the remaining 50% being "locked" by the Hyper-V integration services drivers. VMware uses the same process though its balloon driver to reclaim guest memory.
For most applications, this locked memory is not going to cause a problem as Hyper-V will release memory as the amount of available memory lowers (the buffer threshold can be set on the guest properties).  However, some applications, like Microsoft SQL Server, will try to manage their own memory usage based on the available memory.  In that case, Dynamic Memory could be a problem.
To disable Dynamic Memory and release the driver locked memory in Hyper-V, you will need to shutdown the guest and uncheck Dynamic Memory from the guest memory properties.  Then set the Start-Up memory to the previous maximum memory value.