我正在尝试限制 WSL 使用的 RAM 数量。我有以下配置设置:
[wsl2]
Memory = 4GB
Processors = 1
我知道 GB 是千兆字节,但我试图将内存量限制为 512 兆字节,那应该是 MB 还是 M?
我尝试了 MB 和 M,但都不起作用。如何限制为仅 512MB?我的电脑只有 3GB RAM。我还尝试将值设置为 0.5GB Memory
,但仍然不起作用。
答案1
512MB
应该管用。
来自发行说明:
<size> entries must be size followed by unit, for example 8GB or 512MB
完整文档:
[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.