June 17, 2024

Microsoft has launched the most recent Home windows Subsystem for Linux replace, including Automated Reminiscence Reclaim.

Home windows Subsystem for Linux (WSL) permits builders to run a Linux occasion with Home windows, giving them entry to Linux software program. WSL is a well-liked possibility for builders creating and testing software program for Linux.

Within the September 2023 replace, Microsoft has added Automated Reminiscence Reclaim to the listing of options:

When that is set to gradual, after being idle for five minutes, WSL will slowly begin to launch cached reminiscence in Linux and make it out there as free reminiscence again to the Home windows host. Which means your WSL VM will robotically shrink in reminiscence measurement if you’re not utilizing it!

This works by WSL detecting that you just’re idle by seeing if CPU utilization is repeatedly low for five minutes, after which we begin reclaiming cached reminiscence by utilizing the cgroup reminiscence.reclaim characteristic. We reclaim a set portion of your VM’s reminiscence measurement, which is calculated in order that in case your VM was filled with cached reminiscence it will go to zero cached reminiscence after half-hour (e.g: You probably have 3000MB of reminiscence, we reclaim 100MB each minute). The reminiscence.reclaim cgroup characteristic permits us to intelligently reclaim a portion of reminiscence over time, placing a stability between efficiency and reminiscence utilization. Nonetheless, this characteristic does require disabling cgroups v1 in WSL, which might trigger some points. In early testing we seen that this may break the docker daemon when operating it as a service in WSL, and so in the event you’re utilizing this characteristic we suggest you utilize Docker Desktop in your docker wants. We’re working with the Docker group to handle this sooner or later.

Microsoft has additionally improved Automated Disk House Clear Up:

WSL digital exhausting disks (VHDs) develop in measurement as you utilize them, and now with this characteristic enabled they may robotically shrink in measurement too! This new setting robotically units any new VHD to be a sparse VHD, which might robotically scale back their measurement. Moreover, we’ve added the wsl –handle–set-sparse <true/false> command to will let you set your current distros to be sparse or not in the event you’d like.