Microsoft has implemented memory reclaiming in WSL2 (Windows Subsystem for Linux)

Microsoft announced expanding the capabilities of the WSL2 layer, which allows Linux executable files to run on Windows. In experimental builds Windows Insider (build 19013) has introduced support for memory reclamation in the WSL2 layer, enabling the release of memory occupied by processes running in the Linux kernel-based environment.

Previously, when applications or the kernel increased memory usage, memory was allocated to the WSL2 virtual machine but remained locked and was not returned to the system, even after the resource-intensive process ended and there was no further need for the allocated memory. The Memory Reclamation mechanism allows reclaimed memory to return to the host OS and automatically reduce the virtual machine's memory size. This includes not only memory released by user processes but also memory used for caching in the Linux kernel. For instance, with high disk activity, the size of the page cache increases, which stores the contents of files during file system operations. After executing "echo 1 > /proc/sys/vm/drop_caches", the cache can be cleared and memory returned to the host OS.

The implementation of Memory Reclamation is based on
a patch, proposed by Intel engineers for inclusion in the main Linux kernel to enhance the capabilities of the virtio-balloon driver and memory management system. This patch is designed for use in any guest systems to return unused memory pages to the host system and can be applied with various hypervisors. In the case of WSL2, the patch has been adapted to return memory to the Hyper-V hypervisor.

Recall that the second version of WSL differs features a full Linux kernel instead of an emulator that dynamically translates Linux system calls into Windows system calls. The Linux kernel provided in WSL2 is a Linux kernel based on the release 4.19, which runs in a Windows environment using a virtual machine already being used in Azure. Updates for the Linux kernel are delivered via the Windows Update mechanism and are tested in Microsoft’s continuous integration infrastructure. The WSL2-specific patches applied to the kernel include optimizations to reduce boot time, lower memory consumption, and keep only the minimally necessary set of drivers and subsystems in the kernel.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster