1. In Windows 10, the system felt severely laggy. Checking Task Manager showed memory usage at 98%. A process named Vmmem was consuming as much as 2.1 GB of memory. See Figure 1.

2. The Vmmem process is a synthetic system process used to represent the memory and CPU resources consumed by a virtual machine. In other words, if you see Vmmem consuming a large amount of memory and CPU resources, it means your virtual machine is consuming a large amount of memory and CPU resources. To stop it, shut down your virtual machine.
3. I believe the cause is likely that Docker is running on the operating system, and the development in progress may also be using it. Try finding Docker Desktop and quitting it, and the task should disappear. Alternatively, set memory and CPU usage limits for Docker Desktop.
4. Open Docker Desktop, then go to Settings – Resources – ADVANCED. You are using the WSL 2 backend, so resource limits are managed by Windows. You can configure limits for the memory, CPU, and swap size allocated to WSL 2 in the .wslconfig file. See Figure 2.

5. Click .wslconfig, which links to Advanced settings configuration in WSL: https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig . WSL 2 runs as a lightweight virtual machine (VM), so you can use virtualization settings to control the amount of memory or processors used.
6. In PowerShell, use cd ~ to access your home directory (usually the user profile C:\Users\<UserName>). Directory: C:\Users\Lenovo. See Figure 3.

PS C:\Windows\system32> cd ~
PS C:\Users\Lenovo> ls
Directory: C:\Users\Lenovo
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2021/12/20 18:13 .aws
d----- 2021/12/20 18:13 .azure
d----- 2021/12/25 16:22 .docker
d----- 2021/12/20 16:23 .rdm
d----- 2022/1/10 10:27 .ssh
d-r--- 2021/12/19 10:29 3D Objects
d-r--- 2021/12/19 10:29 Contacts
d-r--- 2022/1/17 9:05 Desktop
d-r--- 2022/1/7 9:32 Documents
d-r--- 2022/1/25 16:35 Downloads
d-r--- 2021/12/19 10:29 Favorites
d-r--- 2021/12/19 10:29 Links
d-r--- 2021/12/19 10:29 Music
dar--l 2022/1/25 9:07 OneDrive
d-r--- 2021/12/19 10:31 Pictures
d-r--- 2021/12/19 10:29 Saved Games
d-r--- 2021/12/19 10:30 Searches
d-r--- 2022/1/10 9:04 Videos
-a---- 2021/12/30 16:01 1387 .bash_history
-a---- 2021/12/27 15:30 177 .gitconfig
-a---- 2022/1/24 10:34 20 .lesshst
-a---- 2021/12/30 9:16 29 .minttyrc
-a---- 2022/1/17 13:54 121 .yarnrc
-a---- 2022/1/6 18:00 206 _netrc
PS C:\Users\Lenovo>
7. Since the file C:\Users\Lenovo\.wslconfig does not exist, create a new one. processors: The number of processors to allocate to the WSL 2 VM. The same number of processors as on Windows. memory: The amount of memory to allocate to the WSL 2 VM. 50% of total memory on Windows or 8GB, whichever is less; on versions prior to 20175: 80% of total memory on Windows. swap: The amount of swap space to add to the WSL 2 VM, 0 for no swap file. Swap storage is disk-based RAM used when memory requirements exceed the hardware device limits. 25% of memory size on Windows rounded to the nearest GB. localhostForwarding: A boolean value specifying whether ports bound to wildcards or localhost in the WSL 2 VM should be connectable from the host via localhost:port. My computer has 16 GB of memory and an Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz 2.71 GHz processor, with 2 cores and 4 threads.
# Settings apply across all Linux distros running on WSL 2
[wsl2]
# Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
memory=2GB
# Sets the VM to use two virtual processors
processors=2
# Specify a custom Linux kernel to use with your installed distros. The default kernel used can be found at https://github.com/microsoft/WSL2-Linux-Kernel
# kernel=C:\\temp\\myCustomKernel
# Sets additional kernel parameters, in this case enabling older Linux base images such as Centos 6
# kernelCommandLine = vsyscall=emulate
# Sets amount of swap storage space to 8GB, default is 25% of available RAM
swap=4GB
# Sets swapfile path location, default is %USERPROFILE%\AppData\Local\Temp\swap.vhdx
# swapfile=C:\\temp\\wsl-swap.vhdx
# Disable page reporting so WSL retains all allocated memory claimed from Windows and releases none back when free
# pageReporting=false
# Turn off default connection to bind WSL 2 localhost to Windows localhost
localhostforwarding=true
# Disables nested virtualization
# nestedVirtualization=false
# Turns on output console showing contents of dmesg when opening a WSL 2 distro for debugging
# debugConsole=true
8. Run wsl –shutdown to shut down the WSL 2 VM, then restart the WSL instance (i.e., restart Docker Desktop) for these changes to take effect. See Figure 4.

PS C:\Users\Lenovo> wsl --shutdown
PS C:\Users\Lenovo>
9. Checking Task Manager again showed memory usage at 92%. The process named Vmmem was still consuming close to 1.8 GB of memory, which is a slight decrease, and the system lag has eased somewhat. See Figure 5.

10. If you run wsl –shutdown to shut down the WSL 2 VM and then do not restart the WSL instance (i.e., quit Docker Desktop). Checking Task Manager again showed memory usage at 80%. The process named Vmmem has disappeared. See Figure 6.

11. In summary, if you need to run Docker Desktop in Windows 10, a memory configuration of 32 GB might be more appropriate. When planning to purchase a new laptop, I will configure it with 32 GB of memory.
