Skip to content

Instantly share code, notes, and snippets.

@nikAizuddin
Last active June 18, 2022 10:03
Show Gist options
  • Save nikAizuddin/b1f0c73b65f770a68827afab7f8d0894 to your computer and use it in GitHub Desktop.
Save nikAizuddin/b1f0c73b65f770a68827afab7f8d0894 to your computer and use it in GitHub Desktop.
Limit WSL2 CPU and Memory

Limit WSL2 CPU and Memory

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment