I am using wsl and the problem is it loves ram. I tried to limit it by adding %USERPROFILE%/.wslconfig
this is what the file looks like:
[wsl2]
memory=2GB
swap=0
processors=2
and yet the Vmmem process happily passes that memory limit by a lot.
I tried wsl --shutdown and even restarting the computer.
none helped
I've had some issues troubleshooting why, suddenly, my .wslconfig stopped working. A few things to consider:
[wsl2]swapfile= parameter, make sure that:
C:\\Users\\Username\\AppData\\Local\\Temp\\swap.vhdxmemory=2GB or swap=16GB
swap=250GB anything more than that just results in this parameter being entirely ignored.In cases where you may need more than 256GB of swap, there is an inelegant solution that I've occasionally used (since I don't often need more than 16GB of swap), you will need to specify a swapfile inside the WSL2 shell as an additional swapfile space. The problem is that the mounted swapfile is not persistent, and also doesn't work in /etc/fstab or in /etc/wsl.conf (I've tried automounting, and it just doesn't work with swap files). Here are the commands:
sudo fallocate -l 256G /swapfile (in this example, it's 256GB - notice that it ends in just a "G" and not "GB" like above) - this will create a file in the root called "swapfile" that is 256GB large.sudo chmod 600 /swapfilesudo swapon /swapfile - this will mount the swapfile as a swap space on the systemfree -m or swapon --show to see if the swapfile was mounted and available to the system.Good luck to anyone who comes across this as it took me pouring over dozens of related posts to suss out some of these details.
Check your filename , make sure it is strictly ".wslconfig" , not like ".wslconfig.txt" , I faced this problem and when I checked using cmd I found out my file is saved as ".txt" . Few important points to note:
You can read more about it here: https://learn.microsoft.com/en-us/windows/wsl/wsl-config
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With