How can I reduce the consumption of the `vmmem` process?

Solution 1:

Daniiel B is on the money. To turn off Vmmem simply go into Powershell or whatever terminal you like to use under admin rights and enter the command wsl --shutdown, when your done with playing in wsl1/2.

Solution 2:

vmmem even after docker has shut down, will run for a few seconds up to 1 minute before completely shutting off. So try shutting down your containers and docker and it should disappear soon enough.

The accepted answer talks about shutting down WSL (the windows subsystem for Linux) which makes sense if you actually opened and installed a distro, but since you mentioned about Docker, i'm guessing your vmmem is just showing the usage of docker containers only.

Here's a nice explanation from a trustworthy individual : https://devblogs.microsoft.com/oldnewthing/20180717-00/?p=99265

Edit:

Considering the main question was about how to reduce the consumption of RAM, and since you're using docker; take a look at : Docker Resource Contraints

More specifically the --memory=2g parameter, you can limit the RAM a container will use, and in turn vmmem itself will use less RAM as well.

Solution 3:

I edit the WSL config to limit the memory usage as mentioned here.

# turn off all wsl instances such as docker-desktop
wsl --shutdown
notepad "$env:USERPROFILE/.wslconfig"

Set the values you want for CPU core and Memory:

[wsl2]
memory=3GB   # Limits VM memory in WSL 2 up to 3GB
processors=2 # Makes the WSL 2 VM use two virtual processors