Run the following command using powershell
without as Administrator
:
notepad "$env:USERPROFILE/.wslconfig"
Put the following lines if you want to limit your WSL2 to 4GB of RAM and 2 CPUs:
[wsl2]
memory=4GB
processors=2
Shutdown your WSL2 Ubuntu 22.04:
wsl --shutdown Ubuntu-22.04
Now, start your WSL2 Ubuntu 22.04 has been limited to 4GB and 2CPUs.