Unless something has gone very sideways, there should be only one not-quite-VM involved in running Linux containers using Docker Desktop for Windows; the one which runs WSL. Docker runs every container as a Linux namespace (like regular docker) inside a specialized WSL 2 distro, each of which also runs as a Linux namespace inside a single Linux root.
This memory it uses is mostly swappable. You can check this with Process Explorer or the like - look at the "vmmemWSL" process when it's idle and you can see the working set drop back.
It usually doesn't shrink much below 2GB because it doesn't free the Linux page cache until the Linux kernel frees it, but you can poke this manually with `echo 1 > /proc/sys/vm/drop_caches`
Here for more details: https://devblogs.microsoft.com/commandline/memory-reclaim-in-the-windows-subsystem-for-linux-2/
We’ve added a new Windows Subsystem for Linux (WSL) feature in Windows Insider Preview Build 19013: Memory Reclamation for WSL 2! Previously, when the memory needs of the WSL2 Virtual Machine (VM) would grow, either from your workflow or by the Linux kernel,
@mcc WSL2 will use up to 50% of your memory with it's default settings. Docker seems to escalate maxing out wsl memory usage.
You can limit this by creating a .wslconfig file in your user directory. Nice write up here by @willem_meints https://fizzylogic.nl/2023/01/05/how-to-configure-memory-limits-in-wsl2
One of the downsides to building machine learning models is that you need quite a bit of power in your machine. I've just upgraded my home desktop that I use for side projects and experiments to 64GB of memory because it was clearly no longer up to the task. However, when I booted up my WSL linux distro, it couldn't get more than 32GB of memory. Time to figure out how to fix that! In this quick post I'm showing you how you can limit or increase the memory available to your WSL2 distributions. Let's go!
@mcc Is Core Isolation Memory Protection on? Can Hyper-V or WSL2 run?
I sometimes disable those to get VirtualBox and VMware to run more smoothly. Although recently discovered on Windows 11, memory integrity causes the OS to be virtualized, even if I tried to turn that off. Although that sounds like the opposite of your problem, where the VM stuff is disabled when you want it enabled.
IME some Wintel motherboards seem to just lose or change their BIOS settings randomly at intervals for no apparent reason.
For example one of my previous desktop systems at work (a brand X build) changed its settings to maximum overclocking, several times. It ran nice and fast at 4+ GHz except when it would overheat and crash. Then I'd check, find out it had turned on extreme overclocking, and turn it off again until the next time.
Kind of disturbing, really.