#SharePointProblems | Koskila.net

Solutions are worthless unless shared! Antti K. Koskela's Personal Professional Blog

How to solve Vmmem consuming ungodly amounts of RAM when running WSL?

β€’ koskila
Reading Time 6 min
Word Count 958 words
Comments 23 comments
Rating 5 (14 votes)
View

This was another (luckily pretty shallow) rabbit hole down some corporate IT and weird default configurations by our favorite tech-daddy Microsoft. In this article, I will describe one possible reason for a process called Vmmem.exe consuming enough RAM to crash pretty much everything else running on your machine.

But let's take a step back first - what happened?

AI-powered summary: Optimize WSL and Docker to Prevent Vmmem Overconsumption

Experiencing sluggish performance and crashes due to Vmmem’s high RAM usage? This article offers a solution for WSL2 users. The issue stems from WSL reserving more memory than necessary, affecting other applications. The fix involves shutting down WSL, locating and editing the .wslconfig file to limit memory usage, and restarting Docker. This simple adjustment can significantly improve your development environment’s efficiency.

Problem

I was developing some Azure IoT Edge modules (as one does), when my dev laptop was starting to feel a bit sluggish. That's nothing out of the ordinary, though - I often have more than 3 tabs open in Chrome, so it's not unusual for the machine to start slowing down, especially if I try having any Electron apps open.

But then one of said Electron apps started behaving even more annoyingly - namely, Teams started crashing and restarting in a loop.

I don't care too much about Teams not running every now and then, but a restart loop flashing on one of my screens DOES start to bother me after a while. So I started looking into it.

This is what's shown for about 3 seconds before Teams automatically restarts (only to crash again).

Microsoft Teams in a crash-restart -loop

Microsoft Teams in a crash-restart -loop

The obvious first step was to fire up Task Manager and see what was up. So, what do I find?

I wonder if it's just Chrome and a couple of Electron apps doing this, or do we get to blame something else for this memory usage?

I wonder if it's just Chrome and a couple of Electron apps doing this, or do we get to blame something else for this memory usage?

Oh. Okay. That's not normal. 28 GB of RAM in use even though I'm not running a full SharePoint farm on this laptop? That's a bit weird. Is OneDrive acting up again?

Let's take a look...

Vmmem.exe consuming somewhat unreasonable amounts of RAM. I mean, just compare it to Chrome...

Vmmem.exe consuming somewhat unreasonable amounts of RAM. I mean, just compare it to Chrome...

Ohhhhhh. That's even more abnormal, and won't be solved by simply shutting down all 15 OneDrive clients on my machine. Vmmem is something else. What's going on?

Reason

This one was caused by WSL acting up, as Vmmem is the process that represents the memory allocation for your Virtual Machines, and I was most definitely running a bunch of Docker containers as part of my development workflow.

So Docker, with WSL, has incredibly high memory consumption.

WSL reserves a lot of memory, even if it doesn't need it. On current Windows builds (technically speaking, pre-20175, but that's a Windows Insiders build, so most of y'all out there don't have it), WSL can consume up to 80% of your memory. This has been changed in later builds to be 50%, up to 8GB. Which is still non-trivial, if you plan to run Teams and Chrome at the same time with WSL.

Personally, I ran into this issue on my work laptop, which is running an archaic version of Windows 10 anyway (not something I chose, but hey, that's corporate IT for you). And probably will be, until Windows 12 is out. So no Insider builds for me (unless Microsoft leaks them in the Current/GA channel again).

https://twitter.com/koskila/status/1445710003147399173?s=20

Anyway, the gist of the story is, that when running Docker on WSL (in my case, for developing Azure IoT Edge modules), you might find yourself running out of memory very, VERY easily. 😁

And to be fair, this can happen even if you don't actually have any containers running in Docker in WSL. WSL alone might just do.. Something, and consume 9 gigabytes of RAM. I guess that's just a thing Linux does if left alone? Who knows. But it needs a bit of trimming.

As I have learned the hard way over the last few years (avoiding) working with it.

Luckily, this is one of the easiest performance issues to fix, ever. Let's get to it, then!

Solution

This applies to WSL2. If you're running WSL1, you probably shouldn't. Be running it, I mean. This article will explain how to update: Upgrade from WSL 1 to WSL 2 in Windows 10 to fix Docker

Anyway - on to the topic of today!

Time needed:Β 20 minutes.

How to solve Vmmem consuming ungodly amounts of RAM when running Docker on WSL?

  1. Shut down WSL

    First of all, we'll want to get rid of WSL to free up some resources and make sure it picks up our configuration changes later on.

    Run this on your command line:

    wsl --shutdown

  2. Find your .wslconfig file

    Okay, so we need to find the configuration file for WSL. Navigate to %UserProfile% (just paste that text as-is in the address bar of Windows Explorer), and see if you have a .wslconfig file available (make sure you have dotfiles visible first!)

    Or you can try adding %UserProfile%/.wslconfig in a text editor directly.

    If it doesn't exist yet, don't fret - that's normal. Just create it.

  3. Edit your .wslconfig file to limit memory usage

    Okay, configuration abound. You should have something like this in the file:

    [wsl2] memory=2GB
    If you don't have it, add it!

  4. Restart Docker

    If you were using Docker, that is :) If you had some other workload, just fire up WSL or whatever depends on it, and it should pick up your new configuration!


And that's it! Did it help in your case? Let me know in the comments section below!

References

Comments

Interactive comments not implemented yet. Showing legacy comments migrated from WordPress.
Kevin Barrett
2022-01-31 06:26:07)
thanks for writing this up to share. It was helpful for me. i.e. it works!
Antti K. Koskela
2022-02-04 14:01:34
Thanks for your comment, Kevin - happy to hear it helped!
2022-04-01 20:51:20)
helped
Antti K. Koskela
2022-04-04 16:41:18
Thanks for letting me know, mr./mrs. "a" πŸ˜…
Vlad
2022-05-26 17:31:23)
Is there any other solution rather than "limiting" whole ram? how to enforce vmmem process release the consumed ram which is not used by vm at the moment?
2022-06-11 21:58:13
Hi Vlad, Thanks for your insightful question. I think WSL is hogging the memory for filesystem caching - here's a long thread on how Microsoft is trying to make it better. What you can do is running wsl --shutdown. I know - not pretty... 😐
Julien de Charentenay
2022-06-23 11:03:31)
I have been experimenting with WSL + Ubuntu and had the same issue. Worked like a treat so far. There is something with WSL that is puzzling me. I have a circa 120GB hard-drive that is mostly full - but for some reason ubuntu (under WSL) reports a 250GB disk space (mostly empty)...
Antti K. Koskela
2022-08-18 09:32:19
Hi mate, That's an interesting point - I guess Ubuntu doesn't really know the actual capacity of the virtual disk and just reports the maximum nominal size. The host will run out of disk space way before Ubuntu thinks the virtual disk is full... πŸ˜€
Nadav
2022-06-28 18:36:15)
This worked for a little bit -- I had to restart my computer, but once I did, I saw vmmem sitting nicely in its 2GB holding cell. But a bit later its memory usage crept up to 3.2GB, and the next day when I had to rebuild one of my docker images, it jumped all the way up to 10GB. Any idea why it's not staying within the limits that I placed on it?
Nils
2022-08-29 16:17:05)
Just a quick additional note: This is not just docker specific problem, but it happens also in other situations. Thank you for the fix! :)
Antti K. Koskela
2022-12-01 12:29:32
Hi Nils and thanks for the comment! Yeah, you're correct - I ran into this one with Docker, but I suppose no matter how you use WSL, you can encounter this issue. Either way, the fix should be the same :)
Hotdin Gurning
2022-08-30 00:11:00)
Good article mate, but.. it seems to me that we need another solution rather than limiting memory usage. +1 reason to move from windows to linux.
Antti K. Koskela
2022-12-01 12:30:25
Thanks! That is definitely one way to look at it... 😁
tos
2022-09-14 10:11:37)
Thank you Antti for saving the day ! Ubuntu was crashing when docker could not extract a multi-GB layer. The Ubuntu window would just close without an error message of any kind.
Antti K. Koskela
2022-12-01 12:33:30
Hey mate, happy to be of help! Yeah, plenty of symptoms this one could cause.
Sarah
2022-10-03 08:02:51)
Hi Antti, Thanks for opening this discussion. It's pretty crazy that a problem like this was even allowed to exist. On my side what I've noticed, is that when I limit the memory in .wslconfig, wsl reaches that limit and then crashes and restarts. This happens with any limit between 2 and 5GB while running one docker container. I would have hoped for wsl to use memory more sparingly with a limit. Do you have any inputs on this topic? If wsl is using as much memory as it does when unlimited, doesn't it need that memory to function properly? Best, Sarah
Antti K. Koskela
2022-10-27 15:27:09
Hi Sarah, Thanks for your comment. This I've not seen - but WSL's GitHub repository has a number of interesting threads about memory management. Something like this: https://github.com/microsoft/WSL/issues/8703 For me, WSL behaves well with the limits. I wonder if your docker container is just too much for WSL to handle? πŸ˜ƒ I know - not very scientific. But you could try limiting how much your container uses of the (inherently limited) memory WSL has to offer? And opening an issue at WSL's GitHub repo might be a good idea too! Cheers, Antti
John T. Deer
2022-10-13 18:20:51)
If it doesn’t exist yet, don’t fret – that’s normal. Just create it.
If you don’t, add it!
I couldn't help but chuckle as I followed your instructions. Ty for your guidance!!!
Antti K. Koskela
2022-10-27 14:45:31
Happy to hear it helped! πŸ˜…
Federico
2022-10-26 21:48:45)
Thank you! It helped me
Antti K. Koskela
2022-12-01 10:33:47
Happy to hear it was helpful, Federico!
Toan
2022-11-22 11:32:34)
Thank you a lot.
2022-11-29 14:14:47
Happy to be of help, Toan!
Whitewater Magpie Ltd.
β€’
Β© 2025
Static Site Generation timestamp: 2025-08-12T07:18:34Z