First ensure that the .wslconfig file is defined in the Users folder e.g. C:/Users/yyurijj/.wslconfig
If you have already created the file you can skip to number 3.
- You can use this command "notepad.exe %UserProfile%/.wslconfig" in the windows explorer address bar
then paste the text below as the content for the file
[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=4
For more wsl configuration options please use this link https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconfig
- Save the file
- Run the command "wsl --shutdown" to stop the wsl service
- Run the command "restart-service LxssManager" in PowerShell running as administrator to restart wsl
The trick is to ensure that you shut down and restart wsl after making changes to the config file.