WSL vmmem High Memory Usage: Diagnose and Limit WSL 2 Memory
Inspect Linux processes and cache behind vmmem usage, then safely apply a WSL 2 memory limit with .wslconfig.
If vmmem or VmmemWSL uses a lot of memory on Windows with WSL 2, first distinguish Linux processes from cache. If Windows is under memory pressure, you can set a memory limit for the WSL 2 virtual machine in .wslconfig in your Windows user profile. All WSL 2 distributions share that limit, and setting it too low can cause failed builds or more swapping.
AI-generated conceptual illustration of memory use between Windows and a WSL virtual machine. It is not an actual screenshot or an exact architecture diagram.
Documentation checked on 2026-11-25. The commands and configuration below are illustrative examples based on Microsoft documentation; they were not run in a Windows or WSL environment for this article.
A high vmmem number alone does not prove a memory leak
WSL 2 runs Linux distributions in a lightweight virtual machine. The VM memory shown in Task Manager can reflect Linux applications, the kernel, file cache, and more. A number that does not immediately fall after a large build or file operation does not by itself establish a leak. Check both overall Windows memory pressure and usage inside Linux. WSL version comparison
First, check the running distributions and WSL version in Windows PowerShell.
If --version is not recognized, WSL may be an older version. The VM settings below apply to distributions whose VERSION is 2 in --list --verbose. Basic WSL commands
In the distribution's Linux terminal, inspect the following:
In free, available estimates memory available for new work, while buff/cache includes caches. RSS in ps is a clue to resident memory by process. Because memory can be shared, do not add RSS values and treat the sum as total VM usage. Check any containers or background builds as well. free manual
Set a memory limit for the whole WSL 2 VM
Before changing settings, check for an existing %UserProfile%\.wslconfig and back it up. If it does not exist, open an editor from Windows PowerShell:
If the file already has settings, preserve them and add or change only the necessary item under [wsl2]. The following is an example; 8GB is not a recommendation for every PC.
memory limits the whole WSL 2 VM, not each distribution separately. Microsoft's current documentation lists the default as 50% of total Windows memory. Choose a value based on both your workload and the headroom Windows needs. .wslconfig lives in the Windows user profile and does not apply to WSL 1. WSL may start with defaults even when the file is malformed or misplaced, so also check that it is not named .wslconfig.txt. Microsoft WSL configuration documentation
Save work and restart the entire VM to apply changes
After saving the configuration, first stop or save active builds, servers, containers, and unsaved work in every distribution. The following command shuts down all running WSL distributions and the WSL 2 VM, not just one distribution.
Then reopen the desired distribution and check total memory with free -h, as well as Windows Task Manager. Different display units and system reservations mean the displayed value need not match the configured number exactly. You can also check restarted distributions with wsl --list --running. See the Microsoft documentation for configuration and shutdown scope.
Cache reclamation and the memory limit are different settings
memory limits the memory available to the VM; autoMemoryReclaim controls cached-memory reclamation. Microsoft's current documentation places the latter under [experimental], describes disabled, gradual, and dropCache, and lists dropCache as the default. Support and defaults can vary by version, so check wsl --version and the documentation for your version first. There is no need to add the setting without understanding its effects. Official setting descriptions
A limit that is too low can slow builds, model execution, or containers, or cause them to be terminated for lack of memory. Swap uses disk separately from RAM; a small memory limit does not eliminate storage requirements. Adjust while comparing free -h available and swap, active workloads, and free Windows memory. This article does not measure performance improvements on an actual device or behavior on a particular WSL version.
Related article:
Restart WSL Safely: shutdown vs terminate and Configuration Changes