[wsl2] memory=4GB
例如限制内存为4G,将上述两行配置保存到用户根目录,文件名为 .wslconfig,注意前面有个点
比如我的目录为 C:\Users\mayb\.wslconfig
其它一些配置及说明
[wsl2]
memory=6GB
swap=0
localhostForwarding=true
[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