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

I installed docker on windows home which uses WSL2 as a backend. However, since doing this a process called vmmem seems to be consistently consuming a lot of computational resources. I ran docker stop $(docker ps -aq) to kill all running containers (there were 12 - oops) which has improved the issue significantly. However, even after closing docker down vmmem is still taking ~1.5 - 2Gb of ram and ~20% CPU. Since there are no longer any containers running, shouldn't the resource consumption of vmmem be minimal? How can I reduce the consumption of the vmmem process?

2

10 Answers

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.

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

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 :

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.

3

Restart WSL2, by running the following command in PowerShell right click and run in Administrator mode:

Restart-Service LxssManager

The memory is being consumed by Linux to cache files. It can be seen in the buff/cache section of free command. To drop the cache, simply run echo 3 | sudo tee /proc/sys/vm/drop_caches.

1

If you want to stop vmmem process, try this way

  1. open start menu -> find 'Hyper-V Manager' just by typing
  2. stop the virtual machine -> right-click -> turn off

enter image description here

According to this thread: , using memory setting in .wslconfig doesn't always work.

Solution seems to be to:

  1. Add this to \Users\<USERPROFILE>\.wslconfig (create the file if it doesn't exist)
[wsl2]
guiApplications=false
  1. Restart wsl by running wsl --shutdown in powershell or command prompt (it says shutdown but it actually stops and restarts all running wsl distributions)

In my case I do not have WSL installed but do have Docker. I had shut down the docker process ungracefully then noticed some time later that vmmem was using a lot of CPU. Windows did not allow me to kill the vmmem process.

I had to open Docker again and shut it down gracefully via the system tray icon. After that vmmem was no longer running at all.

4

Could it relate to this????

For my issues, high CPU and high RAM usage by vmmem, I have tried all the solutions I could look up here and elsewhere for WSL2. It seems that for some types of tasks, WSL2 will eat up your memory and not spit it out when done...

Exceptions for using WSL 1 rather than WSL 2:

  • WSL 2's memory usage grows and shrinks as you use it. When a process frees memory this is automatically returned to Windows. However, as of right now WSL 2 does not yet release cached pages in memory back to Windows until the WSL instance is shut down. If you have long running WSL sessions, or access a very large amount of files, this cache can take up memory on Windows.

I don't need WSL2 for this specific task... I'm trying WLS1 now...

I'll post an update on how it goes...

Update: Shifting to WSL1, solves it for me when running many subprocesses, it seems. I have been running way past the time point where it overloads the RAM and comes to a halt.

1

This question was around 2 years old at the time I looked at it and was I was experiencing just now seeing the problems. Might be due to enabling Kubernetes inside Docker for Windows (I'm not sure about that).

I was able to shutdown the Windows Subsystem for Linux (WSL) using the wsl --shutdown command which did free memory but disabled the use of Docker.

So, I updated my ~/.wslconfig file (aka %USERPROFILE%\.wslconfig) as suggested to reduce memory. I believe that helped.

Later found out is my WSL subsystem was out of date and not being updated (by default) with Windows Updates because I had disabled Receive updates for other Microsoft products when you update Windows.

So I enabled that, and ran wsl --update (in admin shell), and my WSL version was updated from 3/16/21 (Kernel Version 5.4.72) to today (5/2/22) (Kernel Version 5.10.102.1).

I'm hoping this will also help.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like