You guys already know what is wsl2, so let’s not waste time. I assume at this point, you already have a distro for your WSL2 ready and don’t know how to increase the RAM/memory.
For this example, I’ll be using Debian 12 (Bookworm).

Powershell
Go to your $HOME directory in powershell. If you don’t know what your HOME directory is, just do
echo $HOMEThis would show you the home directory.
After this, we need to create a file called .wslconfig in the $HOME directory. We can do this from PowerShell itself.
notepad.exe .wslconfigNotepad
A new Notepad window might open, in there just type
.wslconfig
[wsl2]
memory=8GBNow, for the memory= value, your value should be equal to or less than your actual Memory / RAM you have.
Let’s say, I have 16 GB of RAM, then I can give 4 GB, 8GB, 10GB, 16 GB etc.. as long as it is within or equal to 16 GB.
Save the .wslconfig file in your $HOME directory.
Sometimes, it would be saved as .wslconfig.txt, you can rename it easily in PowerShell.
mv .wslconfig.txt .wslconfigRestart your WSL2
After this, if your WSL2 is already running, restart it.
wsl --shutdownAnd now open, any distro you have.
wsl -d DebianNow check how much RAM/memory you have 😄