[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
发现用WSL2内存占用太大,Vmmem进程用久了就占用百分之90+%。最后命令行都打不出来。
解决方案:
在
%UserProfile%\.wslconfig
创建一个文件,里面配置上:配置规范:
注意: .wslconfig文件一定是UTF8的,不要带BOM,还有不要带空格什么的,不然配置文件不会起作用。
References: