It's so annoying really no matter the ram you give it just eats all of it, when i run my projects locally hot reloading becomes so so slow. I dont know why microsoft recommends it and it unbelievebly unusable. Also the problem has been around since the creation of wsl why microsoft didnt find a solution yet ?
You specify the wsl2 ram limit in the config file.<p>By design it will end up using all the allocated ram for caches and linux programs.<p>If you really need to free ram for windows apps you can flush caches by running below as root<p>echo 1 >> /proc/sys/vm/drop_caches
Yeah there seems to be a memory leak in Hyper-V somewhere. Spinning up Docker containers on-demand (like for a local GitHub runner, for example) instantly gobbles up the whole allotment and, on defaults, makes my 32GB work computer totally unusable.<p>I really wish I could just run proper Linux on the metal. Docker under emulation is such a disaster! I don't understand how it's the norm.
By default WSL2 should only be using 8GB ram or 50%, which ever is lower.<p>As far as I know, the high memory usage of WSL2 is due Linux using as much spare RAM as possible for caching and WSL2 having to allocate memory for this cache. Both Linux and Windows memory ballooning under KVM/QEMU manages dynamically manage memory and work around memory caching.<p>I suspect the issue with WSL2 allocated memory being quickly consumed by cache could be currently a limitation of the Hyper-V hypervisor or the WSL2 kernel.