These settings are being respected, as far as I can tell. Since when is it not common sense to assign a reasonable amount to a VM? The only thing that does not seem to work well at the moment is a "memory balloon" RAM allocation scheme. WSL2 is a VM, not a shared memory container. They could do better, but RAM is pretty cheap nowadays and WSLg is IMO the much more productive feature.
SQL Server by design grabs as much RAM as it can, as aggressively and preemptively as it can, because it assumes it's the most important process running on the machine. Which is almost always the case in production environments, and a reasonable default behaviour as a result. If that's not the case, you can easily set resource limits at the application, container, and/or VM level.
(This comment coming from someone who used to have to support running small backup MSSQL instances on Windows 8 tablets.)
Yep this. SQL Server using RAM is by design. If it's using too much because you're using it for dev work then you can simply limit the amount it can access. RAM is there to be used!
It's a perfectly fine design so long as there's one, and only one, program that is maximizing its RAM usage. When you have many programs (e.g. the browser, Teams, slack, every single electron app), then you get loads of contention.
Can't speak for OP but here in Africa I've worked on a two unrelated projects where poor internet connectivity meant it made sense to have a local SQL Express running on a users device, which a service would then try to regularly synchronize with the central server. Makes sense when you are capturing documentation and can make all the decisions in disconnected operation.
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.
It sounds like a very complicated topic, it's crossing multiple isolation boundaries, and pretty risky to implement, too. A bug can be maximally critical.
> 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.
That 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.
Are you sure? I watched the conference and this uses the RDP framework behind the scenes, integrating with Wayland. Why would it consume much more than running natively?
It's not perfect: I run IntelliJ in Arch WSL1 and 1) it crashes every time it opens a .md file athough I have (LIBGL_ALWAYS_INDIRECT=1). I have to put
-Dsun.java2d.opengl=false
-Dsun.java2d.d3d=false
in idea64.vmoptions and disable the markdown plugin (maybe only 1 of them is enough) 2) In Windows, IntelliJ automatically saves files when it loses focus. I have to remember to Ctrl-S all the times with IntelliJ in WSL1 3) IntelliJ can't detect where there's a change in the file system. I have to Reload All from Disk all the times.
WSL2 essentially invalidates one of the primary design criteria of the NT kernel, which is that the kernel itself should be able to service any number of "personalities" to provide userspace compatibility with other operating systems.
In practice, this turns out to have meant DOS, OS/2, and a barebones POSIX workalike. Modern Linux is too huge and provides useful APIs that go against the grain of modern NT, so applications are slow in WSL1 and there are too many impedance mismatches to paper over to make the investment worth the effort.
Sure, but I upload my experiments to a Linux cluster and only use my machine for development. Windows IO performance is more important to me than compute.
That's been going on for a few months already, I have a single Docker image running in WSL2 running SQL Server and it's using 5 GB of memory while idle.
Maybe unrelated but I think it is a Hyper-v (w10) issue, not a WSL one. At least same thing happened to me some days ago on one VM running on Hyper-v, it went crazy and consume all my 32gb of ram. It seems to be fixed after reducing the number of cores available to it.
With WSL2, apps will now use either 50% or 8GB of your available memory.
Happy coding!
[0]: https://github.com/microsoft/WSL/issues/4166