Loading

WSL 限制进程内存

跑 WSL 的过程中,突然发现 WSL 这个进程居然占用到了 6GB,我寻思我在上边只装了个 Rust 的环境,怎么会跑这么多,然后进行了内存限制,步骤如下:

  1. Win + R 运行 %UserProfile%
  2. 新建文件 .wslconfig 并编辑
  3. 编辑以下内容,把 WSL 内存限制到 2GB:
[wsl2]
memory=2GB  # Limits VM memory in WSL 2GB, also can be set to other values
swap=0
localhostForwarding=true
processors=2 # Makes the WSL 2 VM use two virtual processors, also can be set to other values

PS: 如果不使用 WSL 也可以运行命令 wsl --shutdown 给关闭。

posted @ 2024-10-03 15:20  Regnx  阅读(266)  评论(0)    收藏  举报