Go to user’s folder:
cd %UserProfile%
create .wslconfig file with the following content:
[wsl2]
memory=30GB
swap=10GB
and restart WSL in PowerShell:
wsl --shutdown
Ensure the changed was applied:
free -h
               total        used        free      shared  buff/cache   available
Mem:            29Gi       639Mi        28Gi       3.4Mi       145Mi        28Gi
Swap:           10Gi          0B        10Gi


Advanced settings configuration in WSL
https://learn.microsoft.com/en-us/windows/wsl/wsl-config