WSL2 already has Memory Reclaim

WSL2

All Microsoft developers have announced the expansion of the WSL2 layer (Windows Subsystem for Linux) in Windows Insider Experimental Builds (Build 19013). In these they announce that have added compatibility to return a memory system (Memory Reclaim), released by processes running in a Linux kernel-based environment.

Previously, in the case of higher memory consumption by applications or the kernel, memory it was assigned to the WSL2 virtual machine, but after that it remained fixed and did not return to the system, even after the completion of the resource-intensive process and the absence of increased need for allocated memory.

Now with memory reclaim in WSL 2, when memory in Linux is no longer needed, the host can be informed where it will be released and your WSL 2 VM will be reduced in memory size.

Memory reclaim mechanism allows freed memory to be returned to main operating system and automatically reduce the memory size of the virtual machine. In this case, not only memory freed by user processes is returned, but also memory used for caching in the Linux kernel.

User processes are not the only things that use memory in the Linux virtual machine. The Linux kernel also uses many caches, including a page cache, which stores file content to improve file system performance. Let's look at one more real-world example to see how this comes into play.

Eg with high disk activity, the page cache size increases, in which the content of the files is settled during the operation of the FS. After executing "echo 1> / proc / sys / vm / drop_caches", the cache can be cleared and the memory returns to the main operating system.

The memory reclamation implementation is based on a patch proposed by Intel engineers for inclusion in the main Linux kernel to expand the capabilities of the virtio-balloon driver and memory management system.

This feature is driven by a Linux kernel patch that allows small contiguous blocks of memory to be returned to the host machine when they are no longer needed in the Linux guest. We updated the Linux kernel in WSL2 to include this patch and modified Hyper-V to support this page reporting feature.

The specified patch is designed to be used on any guest system to return unused memory pages to the host system, and can be used with multiple hypervisors. In the case of WSL2, the patch is tailored to return memory to the Hyper-V hypervisor.

It is important to remember that the second edition of WSL differs in delivering a full Linux kernel rather than an emulator on the fly that translates Linux system calls to Windows system calls.

WSL 2 is a new version of the architecture thate allows the Windows subsystem for Linux to run the Linux ELF64 binaries on Windows. This new version of WSL 2 uses Hyper-V features to create a lightweight virtual machine with a minimal Linux kernel.

The Linux kernel delivered in WSL2 is based on version 4.19, which runs in a Windows environment using a virtual machine already used in Azure. Updates for the Linux kernel are delivered through the Windows Update engine and tested on Microsoft's continuous integration infrastructure.

WSL2-specific patches used in the kernel include optimizations to reduce kernel startup time, reduce memory consumption, and leave the kernel with the minimum required set of drivers and subsystems.

If you want to know more details about it you can check them out in the original post. The link is this.


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.