New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WSL 2 consumes massive amounts of RAM and doesn't return it #4166
Comments
Thanks for opening the issue. We have a fix for this in the works. |
After moving to WSL2, VmMem seems to be constantly pegging my CPU. Please see attached screenshots. Anything I can do to help your team troubleshoot? Relevant details:
|
I'm experiencing this too. It happens every time I run wsl after some elapsed time (varying from minutes to hours). It continues regardless of what's running in wsl, and I need to issue a Windows insider build: 18922.1000 I assume this really belongs in a new issue, but wanted to group my comment with that of @mithunshanbhag so I'll leave it here. |
Hi, |
Same issue on Win build 18950 |
@benhillis - Do we have a rough ETA on the fix? I'm actually hitting OOM issues on a machine with 32 gigs while just running a normal ninja build that should succeed. Build 18955 |
@zachChilders - ETA on this one is a bit hard unfortunately. Certainly before WSL2 ships to non-insiders. |
how about a workaround? this just started happening for me (with 18965) and it has effectively killed my WSL 2 environment |
Depending of your usage, nocache utility can be used as a workaround to greatly reduce WSL 2 memory consumption, especially if whatever you're running inside it does a lot of filesystem operations... |
does nocache follow children? I could start my shell with "nocache"... |
Haven't tried, but if I understood how nocache works correctly, it should... |
thanks! nocache has changed my env from "completely broken" to "merely sucks" |
Hi, could you explain how nocache should be used? |
Hi @benhillis , any update on when a fix for this might be deployed to insiders? My 8gb of ram is really getting hammered by this issue... :( |
I wrap compilations in nocache to keep limping along. wrapping nocache around a shell works, but breaks emacs. I've also ordered more RAM :-( |
Sorry no firm timeline, certainly before WSL2 is out of Insider builds though. |
Hi @benhillis , do you have a workaround you could recommend though ? |
Well...I need it all day long and the memory consumption goes crazy after only a few minutes (using docker and a quite heavy stack: elastic search, lots of workers, some databases etc). So...not an option unfortunately. Maybe go back to linux while it is not fixed 😎 |
I am facing the same issue. Is there any workaround (except shutting wsl down) for this @benhillis ? |
Not currently. For some additional context this change requires some changes to the Linux kernel that are in the process of being upstreamed. We will be integrating these changes into the WSL2 kernel as soon as we can. |
Workaround: Create a Example
This will still consume the entire 6GBs regardless of Linux memory usage, but at least it'll stop growing more than that. Supported settings are documented here. |
Does this have any negative side effects to be aware of? |
This right here. Also, this: https://github.com/jesseduffield/lazydocker |
For me it did not cause any unexpected issues at all. |
This is working as intended. Microsoft is unable to deliver performance when integrating different filesystems. So they decided to keep everything that is aaccessed in memory... Surprised this isn't common knowledge. |
Don't Panic! Your ram is fine! This is working as intended, you have 8GB of unused RAM and Linux is using it as cache, this is a feature in Linux, not a bug. This makes the system faster, not slower. What you need to test is when Windows requests the RAM back if WSL2 is releasing it. And that is what the configuration |
Nah. People don't have time to understand your logical answer. Whats more likely is its a conspiracy by microsoft to eat your RAM and do evil things with it. 😉 |
When will this be in a stable release? Just a bit cautious about using pre-release. My .wslconfig is using |
Should already be released in 2.1.4 |
Thanks. My WSL version is 2.1.5 already, so that means I don't need a .wslconfig file to set this option? Can I just remove or disable it to avoid any conflict? |
I'm on 2.1.5 (completly uninstalled wsl and re-installed) and wsl still eats up all the memory up to my configured limit (8 GB) in .wslconfig, although my docker containers only need 3 GB. No memory is returned. |
probably because wsl doesn't see your VM as being idle. It has a internal setting <X cpu usage for Y min then trigger memory reclaim. So if your processes still using cpu it won't trigger, as expected. |
This is in stable release now at 2.1.5! For the folks who are on this release and are still not seeing memory be returned can you help us troubleshoot by doing these things:
Thank you! |
I am a bit confused.
Manually setting |
Seeing not many taking @craigloewen-msft 's offer to scientifically showcase microsoft's secret formula (J.K.) for unnecessarily eating RAM, let me take the opportunity to showcase auto memory reclaim working as intended and releasing RAM after using. I'm using Here's the video evidence. Here's my completely subjective personal opinion comment, those who still think WSL2 has RAM eating bug, make sure it is actually a bug, not just user error/skill issue ☮️ |
The remaining issue is that the cache dropping detection method is global WSL resource utilization. If you're running a process that's constantly utilizing resources within WSL, the memory will never be reclaimed; regardless of if the cached data is actually being accessed by anything. |
@Ali-thepro the system distro aka wslg is also running a wayland server & stuffs. You can disable wslg if free memory is that important to you. Also linux could use free memory as cache. You can tweak those too, but those are all linux quarks/features, not really WSL issue. I also have 32GB ram in desktop and gave 16GB in .wslconfig. I can't remember facing a error with 32GB full ram. Seeing your task manager screenshot saying overall memory usage is 50% I'd its very okey, why worry? |
I know it's fine but a couple days ago it wasn't this much. I know right now it's only 3 gb but couple hours ago I shutdown my laptop and as soon as I opened it 6gb was being used. |
after running wsl-shutdown vmmem goes to 1.5 gb but just opening vscode in wsl it goes back up to 3 gb, this issue never happened before. |
IME , Running wsl-shutdown should stop vmmem completely. |
My mistake, I meant after running wsl after shutting it down it takes 1.5gb |
Something is not right with WSL2 with Windows version 10.0.22631, Build 22631. After a fresh restart of the system and nothing running on WSL2, it's consuming 8GB. I was able to reduce it to 4GB by running |
Yes, I did have something similar, nothing super special about the containers, but this time it did fill up the whole 48GB RAM, by using 14GB or 24GB or so. Don't know anymore. I tried updating Windows, wsl --shutdown etc and rebooting. Rebooting didn't help for long. Now I've finally made the %userprofile%.wslconfig file. # Settings apply across all Linux distros running on WSL 2
[wsl2]
# Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
memory=8GB
[experimental]
autoMemoryReclaim=gradual Seems for work for the last days. Currently the vmmem 'process' is using only 2774 MB. |
I'm having the same issue, I'm trying this for a while
|
Same issue:
Before reinstalling windows (just did a fresh reinstall today) i rarely hit 2gb, unfortunately i did not register the exact versions |
@moracabanas When you had We turned that feature on by default in latest WSL pre-release builds and our aim is for it to help tackle the 'WSL holds onto lots of my RAM' problem. |
Your Windows build number: 18917
What's wrong / what should be happening instead: WSL 2 starts using huge amounts of RAM after a while, just using it like normal. At the moment I'm using phpstorm, and did a dump/load of a database.
Vmmem
is using 7 GB of my 16 GB of RAM and not returning any, even though Ubuntu is actually using much less. I have seen it grow until nearly 100% of my system memory is in use, and it will not release it until I shut down the WSL 2 VM.This may or may not be related to #4159
The text was updated successfully, but these errors were encountered: