Create %UserProfile%\.wslconfig, set memory= and processors= under a [wsl2] section, then run wsl --shutdown and wait about eight seconds.
WSL 2 runs in a lightweight virtual machine, and by default that machine is allowed a large share of your total RAM. On a laptop that is also running Docker Desktop, SSMS and a browser, you notice. The fix is a small config file that most people never find out about.
Before you set limits, check what WSL has now. With no .wslconfig it takes about half of the machine’s memory and every logical processor. On my 8GB machine that is 3.7GB and 8 processors:
wsl free -h wsl nproc
Before I set a limit, WSL on my 8 GB laptop had 3.7 GB of memory, about half the RAM, which is the default, and all 8 processors:


Create the Config File
The file lives in your Windows user folder, not inside the distribution:
# create or open it notepad "$env:USERPROFILE\.wslconfig"
A sensible starting point for a 16GB machine:
[wsl2] memory=4GB processors=4 swap=2GB # optional: turn the swap file off entirely # swap=0
Apply It
# stop the WSL virtual machine so the new settings load wsl --shutdown # wait ~8 seconds, then start WSL as normal wsl
The wait matters. WSL keeps the virtual machine alive briefly after the last distribution stops, and starting again too quickly reuses the old settings. Microsoft documents roughly eight seconds.
Check It Worked
From inside any distribution:
free -h
total used free shared buff/cache available Mem: 3.7G 1.2G 2.0G 90.0M 517.1M 2.3G
The total figure should now reflect your limit rather than most of the machine.
Not sure what numbers to pick? Tell Claude how much RAM the machine has and what else runs on it, and ask for a starting .wslconfig. Then check the result with free -h as above.
Related
If SQL Server is part of your day job, my current work lives over at sqldba.blog: production DBA scripts, an error library and the SSMS guide.
Leave a Reply