4 ms·
WSL2 runs in a vm which is integrated with windows, so it actually dynamically requests memory from windows as required. It also can release memory back to win
by voxic11 6y ago
WSL2 runs in a vm which is integrated with windows, so it actually dynamically requests memory from windows as required. It also can release memory back to windows and is basically is represented on the windows side as a windows process.
Unfortunately like a process there is no way for windows to request memory back from linux (besides killing the entire thing). So its up to the linux kernel to decide what to release back.
What that configuration does is limit the maximum amount of memory it can request (what the linux kernel sees as the total system memory). The reason you need to set a limit right now is that the linux kernel will pretty quickly request most of your windows memory to use as page cache if you don't limit it.
Microsoft is working to allow the linux kernel to use the windows page cache instead of maintaining a separate one.
https://github.com/microsoft/WSL/issues/4166#issuecomment-641445502 https://github.com/microsoft/WSL/issues/4166#issuecomment-64...
- siproprio 6y ago> Microsoft is working to integrate the linux disk cache with the windows disk cache to avoid this issue ... since july 2019, a locked discussion, a lot of dupes, and no progress to report thus far.
- 2ion 6y agoIt sounds like a very complicated topic, it's crossing multiple isolation boundaries, and pretty risky to implement, too. A bug can be maximally critical.
- account42 6y ago> Unfortunately like a process there is no way for windows to request memory back from linux (besides killing the entire thing). I have long thought it would make sense to add a way for the OS to ask processes to relinquish memory that they can do without. A lot of processes have memory that they use for caching which can safely be dropped but doing so when the memory is not needed elsewhere unnecessarily limits performance.
- psd1 6y agoThat would require the application to support it. Like, "got anything you can dealloc?" "Oh shoot, now you mention it..." What exists already in the Windows VMM, and I assume other OSes VMMs, is a distinction between allocated and committed. That's likely to be the best that's realistically achievable. The win VMM also has a last-accessed strategy for paging to disk, and de-duplication of shared pages.