34

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
47

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
  • 6
    this doesn't answer the question - I need my dockers to run, but I just want to bound the RAM consumption – Joey Baruch Nov 1 '20 at 16:45
  • That pretty much answer your question. For as long as you use docker (or anything using WLS2 as the backend), you'll see vmmem consuming your RAM. If you run your dockers, vmmem will be there. – luis.espinal Mar 29 at 14:25
  • 1
    @JoeyBaruch Take a look at : docs.docker.com/config/containers/resource_constraints Specifically the --memory=2g parameter, since you're using docker you can limit the RAM it will use when you run it through WSL, and in turn vmmem itself will use less RAM as well since it just represents the total memory used by your containers; and in my parameter example, you'd restrict the container to 2GB of RAM usage only – Lorenzo Apr 15 at 14:07
10

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

1
  • 2
    This works. Close Docker Desktop and after a minute, vmmem disappears from Task Manager. – Tonatio Apr 15 at 7:32
7

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=4 # Makes the WSL 2 VM use two virtual processors
5

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

Restart-Service LxssManager
3

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

1

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
  • Odd, I thought docker on windows only worked with WSL. – CiaranWelsh Dec 4 '20 at 23:28
  • I'm not an expert on the matter, but i did verify that Windows Subsystem for Linux is not checked in my Windows Features list. – Bill Tarbell Dec 7 '20 at 18:19
  • 1
    @CiaranWelsh it only works with WSL for Windows 10 Home, but for other systems like Windows 10 Pro or Enterprise it doesn't need WSL: docs.docker.com/docker-for-windows/install – dhasson Dec 27 '20 at 20:57
  • That makes sense.. I'm on Win10 Enterprise. – Bill Tarbell Dec 28 '20 at 15:16
1

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.