Surely, you have ever seen the Chrome and Android Studio memes about the huge consumption of ram and CPU.
Well... I think we have a new contender for the crown.
The King is dead, hail the new king.
Your majesty: WSL! 👑
That is because have a known issue "WSL 2 consumes massive amounts of RAM and doesn't return it" and can't be solved until today.
Solution
It is not a definitive solution, but we can setup WSL with some advanced configurations to limit his resources.
All next steep need to be done on PowerShell (Windows side).
First, we need to close all terminals that are using WSL, and then shut it down to avoid data corruption running the wsl --shutdown
command.
Create a .wslconfig
file under the windows user profile path.
cd $env:USERPROFILE
New-Item -Path '.wslconfig' -ItemType File
Open this file with VSCode (or any editor that you like)
code .wslconfig
And set limits for the max amount of resources that can take (according to you needs). For example:
# 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=4GB
# Sets the VM to use two virtual processors
processors=2
# Sets amount of swap storage space to 8GB, default is 25% of available RAM
swap=8GB
# Sets swapfile path location, default is %USERPROFILE%\AppData\Local\Temp\swap.vhdx
swapfile=D:\\WSL\\wsl-swap.vhdx
# Turn off default connection to bind WSL 2 localhost to Windows localhost
localhostforwarding=true
For more WSL advanced configuration check the documentation.
Save the file and restart WSL running wsl
command.
It will still consume the entire 4GBs regardless of Linux memory usage and only 2 virtual processors, but at least it will stop growing more than that.
Alternative
If you are still having issues with WSL, you can use Git Bash. It's not a "real" Linux distribution like WSL, but it's a good alternative to emulate an Unixish environment inside windows.

ZSH + Oh My ZSH! on Windows without WSL
Camilo Martinez ・ Oct 11 '22 ・ 4 min read
That’s All Folks!
Happy Coding 🖖
Top comments (0)