Create the file %USERPROFILE%/.wslconfig
Set memory and processors usage:
[wsl2]
memory=512MB # Can use MB or GB
processors=2 # Makes the WSL 2 VM use two virtual processors
To detailed configs, access: https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig