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
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
Solution 3
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 4
Restart WSL2, by running the following command in PowerShell right click and run in Administrator mode:
Restart-Service LxssManager
Solution 5
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
.
CiaranWelsh
Updated on September 18, 2022Comments
-
CiaranWelsh almost 2 years
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 randocker stop $(docker ps -aq)
to kill all running containers (there were 12 - oops) which has improved the issue significantly. However, even after closing docker downvmmem
is still taking ~1.5 - 2Gb of ram and ~20% CPU. Since there are no longer any containers running, shouldn't the resource consumption ofvmmem
be minimal? How can I reduce the consumption of thevmmem
process?-
Daniel B about 4 years
-
CiaranWelsh about 4 yearsLooks like this is a known issue and people are working on it. I'll wait for the fix. Thanks for the link.
-
-
Joey Baruch over 3 yearsthis doesn't answer the question - I need my dockers to run, but I just want to bound the RAM consumption
-
CiaranWelsh over 3 yearsOdd, I thought docker on windows only worked with WSL.
-
Bill Tarbell over 3 yearsI'm not an expert on the matter, but i did verify that Windows Subsystem for Linux is not checked in my Windows Features list.
-
dhasson over 3 years@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
-
Bill Tarbell over 3 yearsThat makes sense.. I'm on Win10 Enterprise.
-
luis.espinal over 3 yearsThat 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.
-
Tonatio about 3 yearsThis works. Close Docker Desktop and after a minute,
vmmem
disappears from Task Manager. -
Lorenzo about 3 years@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 turnvmmem
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 -
Bob Stein almost 3 yearsSimilarly, a minute after closing all WSL terminals,
vmmem
goes away -
Hassan Faghihi almost 3 yearsDocker generate error over unexpected shutdown, is there any better way to turn it off?
-
T.Todua over 2 yearsShould be accepted answer.
-
Diego Lima over 2 yearsthis is it. combining this cache clearing command with limiting WSL memory usage, I'm happy
-
Community about 2 yearsAs it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
-
Admin about 2 yearsOr
wsl --restart