V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
systemcall
V2EX  ›  自言自语

wsl2 很能吃内存,而且 Windows10 抢不过 wsl2

  •  
  •   systemcall · 2021-01-23 16:26:20 +08:00 · 169 次点击
    这是一个创建于 1225 天前的主题,其中的信息可能已经有所发展或是发生改变。

    电脑只有 16G 的内存,装了 wsl2 和使用 wsl2 的 docker-desktop
    wsl2 里面编译点东西,有时候就会把内存占满,之后就连 wallpaper engine 都开始卡,chrome 和新 edge 也开始频繁的重载网页
    关键是 wsl2 吃了的内存,程序不用了之后被 wsl2 用来当缓存了,win10 吃不到内存只能用页面文件撑着

    1 条回复    2021-01-25 13:57:55 +08:00
    jswh
        1
    jswh  
       2021-01-25 13:57:55 +08:00
    Workaround: Create a %UserProfile%\.wslconfig file in Windows and use it to limit memory assigned to WSL2 VM.

    Example
    [wsl2]
    memory=6GB
    swap=0
    localhostForwarding=true
    This will still consume the entire 6GBs regardless of Linux memory usage, but at least it'll stop growing more than that.

    Supported settings are documented here.

    https://github.com/microsoft/WSL/issues/4166
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1534 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 17:15 · PVG 01:15 · LAX 10:15 · JFK 13:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.