Seeing Hyper-V and Docker memory usage on Windows

This post explains how Hyper-V and Docker reserve memory on Windows machines that is outside of the normal process allocations.  It shows how you can see those reservations.

Docker and Hyper-V

Docker Desktop on Windows runs inside a Hyper-V virtual machine.  The virtual machine's memory is sized specified on the Memory setting in the Docker Control panel's Advanced tab.
Docker Desktop memory reservation.
That memory sizing maps directly to the Docker virtual machine's Assigned Memory value that is displayed in the Hyper V Manager Virtual Machines view. Hyper-V locks the virtual machine into memory by Drover Locking the VM's memory.  Memory used for VMs is partitioned away from the rest of the host's processes.
Hyper-V Manager VM's view
Hyper-V guest memory does not appear in TaskManager because it is reserved outside of the normal process structures.

Memory allocation by type with RamMap

Hyper-V virtual machine memory is allocated on the host and Driver Locked to keep it in memory and prevent usage by other Windows processes.  The SysInternals RamMap application displays Windows memory usage by usage type instead of by process.  This image shows that 16GB of memory has been Driver Locked.  This memory is allocated in the kernel outside of any regular Windows processes.
SysInternal RamMap

Weaknesses of the built in tools

Window's built in tools show overall memory usage and memory details by process. There can be huge differences between the two because memory may be allocated outside of the normal process boundaries.

Task Manager's Partial View

Task Manager shows that memory is being used. It does not show how it is used

Task Manager shows the total amount of memory in use via the Performance tab. It shows the memory that it is in use. It does not show how the memory is used.  
Memory in use on Performance tab
The Task Manager Processes view shows the amount of memory used by each process.  The Performance tab above showed 30GB in use.  The Processes tab does not show the virtual machine's memory reservation. The total memory shown consumed in the Processes tab is signficantly less that the amount shown in the Performance tab.

Task Manager Process tab

Resource Manager incomplete view

The bottom pane Windows Resource Manager shows a lot of memory in use.  The top pane again shows a total usage that when summed is missing the virtual machine.

Resource Manager memory usage

SysInternals

RamMap is just one of the components of SysInternals. Microsoft provides SysInternals tools free of charge.  









Comments

Popular posts from this blog

Installing the RNDIS driver on Windows 11 to use USB Raspberry Pi as network attached

Understanding your WSL2 RAM and swap - Changing the default 50%-25%

Almost PaaS Document Parsing with Tika and AWS Elastic Beanstalk