I love Linux and would ideally prefer to work on a Linux system fulltime. However, most companies will force you to use MS Windows.
Thankfully, we now have WSL on Windows making it possible to still do the majority of work in Linux if you prefer.
However, WSL may end up using a lot of resources on Windows which make your system really slow and unresponsive. In most cases, WSL does not need a lot of resources and in cases where it may consume a lot of resources, you do have some options to limit that impact on the rest of the system.
But how would you know when this is a problem? Well, a good indicator is the
vmmem process taking up a lot of memory and hammering your CPU.
The fix? Open a command prompt or powershell window in Windows, and run the following commands:
$ wsl --shutdown $ notepad "$env:USERPROFILE/.wslconfig"
The latter command will open notepad where you will edit the file
~/.wslconfig (in your Windows home directory).
In this file, add the following:
[wsl2] memory=3GB # Limits VM memory in WSL 2 up to 3GB processors=2 # Makes the WSL 2 VM use two virtual processors
You can obviously tweak these numbers for your own use case. For running Docker with a WSL backend and with the Kubernetes engine enabled, I found that 8GB RAM and 4 CPU cores to be the sweet spot to keep my system happy (I have a total of 32GB RAM and 2 cores available on this system).
- WSL Advanced Settings (Microsoft DOcumentation)