I’ve been using WSL2 as my development envorinment for a couple months now. One of the biggest issues I ran into early on was that when building or running tests my host system would freeze up due to WSL using all the resources. According to the documentation this shouldn’t happen but eventually I found the way to limit the resources so I could keep using Windows while compiling/testing.

  1. Create a .wslconfig in your user directory
  2. Add the following with whatever values make sense for you:
    [wsl2]
    memory=12GB # Limits VM Memory
    processors=14 # Limits VM CPUs
    

My system has 16GB of memory and 8 cores with 16 threads so giving 12GB and 14 threads to has been working for me.