Skip to content

Instantly share code, notes, and snippets.

@arthurarty
Forked from xuandinhgl/limit-memory-cpu-wsl.md
Created February 14, 2023 00:12
Show Gist options
  • Save arthurarty/4760b8418a7bea5113f8e494f93b070f to your computer and use it in GitHub Desktop.
Save arthurarty/4760b8418a7bea5113f8e494f93b070f to your computer and use it in GitHub Desktop.
WSL2 Tips: Limit CPU/Memory When using Docker

Turn off all wsl instances such as docker-desktop

wsl --shutdown notepad "$env:USERPROFILE/.wslconfig"

Edit .wslconfig file with notepad and write down these settings:

[wsl2]

memory=3GB # Limits VM memory in WSL 2 up to 3GB

processors=4 # Makes the WSL 2 VM use two virtual processors

And then, from Powershell with admin rights, restart WSL2 by typing:

Restart-Service LxssManager

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