- Microsoft has introduced new experimental features in the latest version of Windows Subsystem for Linux (WSL), such as autoMemoryReclaim, which reduces memory usage in the WSL VM when the CPU is idle.
- sparseVhd is another new feature that allows users to automatically shrink the virtual hard disk size of their Linux distros in WSL.
- The mirrored networkingMode in WSL enables network interfaces from Windows to be mirrored in Linux, improving compatibility and adding new features, but it is currently only available for Windows Insiders running Windows 11 version 22H2.
Windows Subsystem for Linux (WSL) is a handy utility present in Windows 10 and Windows 11 that allows developers to run GNU/Linux environments directly inside the operating system without requiring virtual machines (VMs) or dual-boot configurations. The implementation became generally available via the Microsoft Store about a year ago, making it easier for interested users to install it quickly. Now, Microsoft has rolled out a new pre-release version of WSL with a lot of interesting, experimental features.
The first experimental feature is called autoMemoryReclaim; it enables the WSL VM to reduce its memory footprint by releasing cached memory when it detects your WSL VM's CPU idling. It accepts two arguments: gradual and drop. The first value slowly frees up memory after 5 minutes of CPU idling, over a period of 30 minutes. Meanwhile, the latter instantaneously releases all cached memory after the same 5-minutes threshold has been reached. That said, Microsoft has noted that the gradual configuration causes the docker daemon to break if you're leveraging it as a service in WSL, so use Docker Desktop instead.
Next, we have sparseVhd, which allows users to configure their virtual hard disk (VHD) such that it automatically shrinks in size after some time. It accepts boolean values of true and false, and can be applied to existing Linux distros too.
Another fascinating experimental capability is a new mode for networkingMode called mirrored. It is being offered in addition to the default NAT, and is innovative in the way that it enables network interfaces being utilized on Windows to be mirrored to Linux running in WSL. This enhances compatibility and also adds new features like support for IPv6 and multicast, better compatibility for VPNs, connectivity to WSL using your Local Area Network (LAN), and interfacing with Windows servers directly through Linux using the localhost 127.0.0.1 address. However, there are some known issues in this implementation, and it's currently available only for Windows Insiders running Windows 11 version 22H2.
A similar feature in tow is the firewall setting which accepts boolean arguments of true and false. If set to the former, your Windows Firewall rules will be inherited by the WSL VM, with the ability to also set new Hyper-V Firewall rules specific to WSL network traffic. This capability is also exclusive to Windows Insiders on Windows 11 version 22H2.
Furthermore, setting dnsTunneling to true changes how DNS requests are proxied from WSL to Windows. This should enable better networking for a WSL distro communicating with the internet through a VPN or a custom firewall and networking setup. It also means that you'll get fewer "no network connection" errors inside the WSL distro. This feature is currently locked behind Insider channels on Windows 11 version 22H2 too.
Finally, we have a true configuration for autoProxy. As the name suggests, it empowers users to leverage the Windows proxy settings automatically inside a WSL VM so that you don't have to configure them manually and potentially run into errors. Although it's not walled behind an Insider channel, you still need to be running Windows 11 version 22H2 to take advantage of this feature.
Of course, this may be a lot of information to absorb, so WSL's Product Manager Craig Lowen has also published a handy video explaining how you can utilize these experimental capabilities and configure them correctly too, check it out below:
Also note that there are some other, relatively smaller improvements in tow too, and you can find out more about them in the changelog for WSL 2.0.0 pre-release in the GitHub repository here.