I’m trying to cap the amount of ram WSL uses. I have this config set:
[wsl2] Memory = 4GB Processors = 1 I know GB is gigabyte, but im trying to limit the amount of memory to 512 megabytes, would it be MB? Or M?
I tried both MB and M, but none of them worked. How do I limit to only 512MB?I only have 3GB of RAM on my computer. I also tried to put 0.5GB in the Memory value, still didn't work.
2 Answers
The release notes for this feature say that 512MB is the correct form. Also, this comment on a related Github issue mentions changing it to 512MB and it working, although the thread is locked, so there's no way to confirm that with a reply in that issue.
512MB should work.
From the Release Notes:
<size> entries must be size followed by unit, for example 8GB or 512MB
Full Documentation:
[wsl2] kernel=<path> # An absolute Windows path to a custom Linux kernel. memory=<size> # How much memory to assign to the WSL2 VM. processors=<number> # How many processors to assign to the WSL2 VM. swap=<size> # How much swap space to add to the WSL2 VM. 0 for no swap file. swapFile=<path> # An absolute Windows path to the swap vhd. localhostForwarding=<bool> # Boolean specifying if ports bound to wildcard or >localhost in the WSL2 VM should be connectable from the host via localhost:port (default true). # <path> entries must be absolute Windows paths with escaped backslashes, for example C:\\Users\\Ben\\kernel # <size> entries must be size followed by unit, for example 8GB or 512MB.