WSL2 Vmmem High RAM Usage on Windows 11: .wslconfig & Cache

19 min readBy Yun Sanghun (M. Yun)

When VmmemWSL climbs to 6 GB to 30 GB in Windows 11 Task Manager and refuses to drop after your Docker build, database dump, or container test finishes, the culprit is almost never a traditional memory leak. Instead, the Linux kernel inside the WSL 2 lightweight Hyper-V utility virtual machine retains clean file system page cache (buff/cache in free -m, Cached in /proc/meminfo) in guest physical RAM, while Windows 11 bills every committed guest page directly to the host vmmemWSL working set. In two controlled empirical experiments on a 64 GB (63,131 MB) Windows 11 23H2 workstation running WSL 2.3.26.0 and Docker Desktop 4.38.0 (Docker Engine 27.3.1), we proved that a 4 GB anonymous Python heap allocation returns to Windows automatically on process exit, whereas a 4 GB file write stays locked in vmmemWSL until unlinked, flushed via vm.drop_caches=3, or reclaimed via %UserProfile%\.wslconfig.

.wslconfig Key / CommandSectionDefault WSL 2 BehaviorMeasured Effect on Windows 11 Host
memory=4GB (or 25% to 35% RAM)[wsl2]50% of physical host RAM (30.9 GB on 64 GB PC)Hard-caps vmmemWSL working set (`total = 3914 MB` in `free -m`)
autoMemoryReclaim=gradual[experimental]Disabled (VFS buff/cache stays locked at 0% CPU)Reclaims idle Linux page cache at ~90 MB per 30s back to Windows
sparseVhd=true[experimental]ext4.vhdx grows monotonically on diskAllows Hyper-V virtual disk file size to shrink after file deletion
wsl --shutdown (wait 8s)PowerShell CLI.wslconfig edits are ignored while VM runsCold-boots utility VM and applies new memory ceiling in 11 to 12s

Sizing Docker Compose container mem_limit caps or PostgreSQL buffers inside your new WSL 2 ceiling? Use our Docker Run to Compose Converter and PostgreSQL & PgBouncer Memory Calculator.

Look at the VmmemWSL row, not Vmmem

Before changing any configuration file, verify which process row in Windows 11 Task Manager or PowerShell is actually holding host memory. On Windows 11 systems running both WSL 2 and Hyper-V features (such as Windows Sandbox, Windows Defender Application Guard, or standalone Hyper-V virtual machines), two separate memory manager processes can appear simultaneously: Vmmem and vmmemWSL. On our test workstation, an unrelated Vmmem row sat at a constant 1,036.1 MB even while Docker Desktop was paused in Resource Saver mode, whereas vmmemWSL (PID 19420) tracked the shared WSL 2 utility VM at 6,916.8 MB.

PowerShell Get-Process output distinguishing Vmmem (1,036.1 MB) from vmmemWSL (6,916.8 MB) alongside free -m and /proc/meminfo inside the WSL 2 VM
Comparing Get-Process vmmem* on Windows 11 with free -m inside the WSL 2 VM separates the unrelated 1,036.1 MB Vmmem process from the 6,916.8 MB vmmemWSL utility VM holding 5,439 MB in Linux buff/cache.
WSL2 vmmemWSL memory architecture comparing unbounded Linux buff/cache pinning host RAM on Windows 11 against .wslconfig memory ceiling and autoMemoryReclaim=gradual reclamation
Hyper-V Guest Page-Cache Retention vs Gradual Reclaim: Heavy container builds fill WSL2's Linux buff/cache and keep vmmemWSL bloated on the Windows 11 host until capped with %USERPROFILE%\.wslconfig memory= and experimental autoMemoryReclaim=gradual.

Two kinds of memory, and only one comes back on its own

Because WSL 2 runs a real Linux kernel (6.6.x-microsoft-standard-WSL2) inside a Hyper-V utility VM rather than a syscall translation layer, every Linux distribution on your machine (including Ubuntu, Debian, and Docker Desktop's internal docker-desktop distribution) shares a single virtual machine memory pool (including cached container layers and local wheel caches from Python pip wheel caching & timeout tuning). Inside that Linux kernel, memory allocations fall into two fundamentally different categories with opposite host reclamation behaviors:

  • Anonymous Process Heap (Active(anon) / used in free -m): Allocated by application runtimes (Python, Node.js, Go, Java, PostgreSQL) for variables, buffers, and heap structures. As soon as the process frees that memory or exits, the Linux kernel releases those pages and returns them to Windows within one 30-second polling interval.
  • VFS File System Page Cache (Cached / buff/cache in free -m): Populated whenever you read or write files on disk, such as extracting image layers during docker pull, running npm install, or writing temporary archives with dd or tar. Linux intentionally retains clean cached file pages after the process exits so subsequent reads hit RAM instead of disk.
# %UserProfile%\.wslconfig - Global WSL 2 Utility VM Configuration
[wsl2]
memory=4GB
processors=4
swap=4GB

[experimental]
autoMemoryReclaim=gradual
sparseVhd=true
VS Code editor showing %UserProfile%\.wslconfig with memory=4GB under [wsl2] and autoMemoryReclaim=gradual under [experimental]
Placing memory=4GB under [wsl2] caps total VM RAM at 3,914 MB, while placing autoMemoryReclaim=gradual under [experimental] enables slow background page-cache reclamation (~90 MB every 30 seconds).

Test 1: a 4 GB allocation vs a 4 GB file, no .wslconfig

To isolate how Windows 11 treats anonymous process heap versus file-backed page cache when no %UserProfile%\.wslconfig file exists, we ran our first experiment on a 63,131 MB (64 GB) Windows 11 workstation. Without a custom configuration file, Microsoft's default 50% host RAM rule gave the WSL 2 VM a ceiling of 30,910 MB in free -m alongside 8,192 MB of swap and 16 logical processors. Starting from Docker Desktop's paused Resource Saver state (where vmmemWSL did not appear in Task Manager at all), we launched a throwaway nginx:1.27-alpine container. With the idle container running, free -m inside the container reported used = 729 MB and buff/cache = 1,188 MB, while Windows Task Manager showed VmmemWSL at 2,626.0 MB. We then allocated a 4 GiB anonymous heap buffer in Python using python3 -c "b=bytearray(4*1024**3);import time;time.sleep(60)" &.

Retina container shell output showing free -m before (729 MB used), during (4,909 MB used), and after (948 MB used) a 4 GB Python bytearray allocation inside WSL 2
Inside the WSL 2 container (total 30,910 MB, 16 vCPUs), holding a 4 GB Python bytearray raised used memory from 729 MB to 4,909 MB and VmmemWSL to 6,734.4 MB; once the process exited, used dropped to 948 MB and VmmemWSL returned to 2,778.9 MB.

While the Python process slept for 60 seconds holding its 4 GiB bytearray, Linux used memory jumped by +4,180 MB (from 729 MB to 4,909 MB) while buff/cache barely moved (1,188 MB to 1,237 MB), and Windows Task Manager showed VmmemWSL climbing by +4,108.4 MB to 6,734.4 MB. The critical finding occurred the moment the 60-second timer expired and the Python process exited ([1]+ Done): without any .wslconfig file and without running any cache-flushing command, Linux used dropped back to 948 MB and Windows Task Manager showed VmmemWSL dropping immediately from 6,734.4 MB back to 2,778.9 MB, returning 3,955.5 MB directly to the Windows 11 host. Next, in the exact same container, we wrote a 4.0 GB (4,294,967,296 bytes) file to disk using dd if=/dev/zero of=/tmp/f bs=1M count=4096 and inspected /proc/meminfo alongside Windows Task Manager.

Side-by-side comparison of Docker Desktop exec shell showing Cached 5,394,408 kB after a 4 GB dd file write and Windows 11 Task Manager showing VmmemWSL at 6,916.8 MB
Writing a 4.0 GB file (/tmp/f) with dd pushed Linux Cached memory to 5,394,408 kB (5.14 GiB) and held Windows 11 Task Manager's VmmemWSL row at 6,916.8 MB even after CPU usage returned to 0.06%.

Writing the 4.0 GB file produced the exact opposite result on the Windows 11 host. Even after dd finished in 2.41 seconds (at 1.8 GB/s) and container CPU utilization dropped back to 0.06%, VmmemWSL in Windows Task Manager rose to 6,986.6 MB (6,916.8 MB in our side-by-side capture, 55% of total host memory) and stayed locked at 6,972.2 MB more than 70 seconds later with zero processes running. Inside the container, free -m showed why: used remained at just 960 MB, while buff/cache had jumped from 1,237 MB to 5,439 MB (with Cached: 5394408 kB in /proc/meminfo).

Test 1 Stage (No .wslconfig, total = 30,910 MB)Windows VmmemWSL (MB)WSL used (MB)WSL buff/cache (MB)Host RAM Behavior
1. Docker Desktop in Resource Saver mode0.0 (Row absent)N/AN/AUtility VM paused
2. Idle nginx:alpine container started2,626.0 MB729 MB1,188 MBBaseline VM footprint
3. Python holding 4 GiB bytearray6,734.4 MB4,909 MB1,237 MB+4,108.4 MB anonymous heap
4. Python process exited ([1]+ Done)2,778.9 MB948 MB1,237 MB-3,955.5 MB returned automatically
5. Wrote 4 GB file (dd ... of=/tmp/f)6,986.6 MB960 MB5,439 MB+4,207.7 MB VFS page cache
6. +70 seconds idle (file still on disk)6,972.2 MB960 MB5,439 MBLocked (-14.4 MB change at 0% CPU)
7. Deleted 4 GB file (rm /tmp/f)2,694.8 MB948 MB1,172 MB-4,222.0 MB freed on inode unlink
Benchmark chart comparing VmmemWSL working set, WSL used memory, and WSL buff/cache across all seven stages of Test 1
Seven-stage Test 1 telemetry profile contrasting anonymous heap allocation (Stage 3 to Stage 4, where 3,955.5 MB returned to Windows immediately on process exit) against file-backed page cache (Stage 5 to Stage 6, where 6,972.2 MB remained locked until the file was deleted in Stage 7).

Why does the Linux kernel refuse to release those 5,394,408 kB of cached pages when the guest system is completely idle? Inspecting the granular fields of /proc/meminfo 70 seconds after dd completed reveals the architectural mismatch between Linux VFS accounting and Hyper-V host memory billing. Inside the WSL 2 guest, Dirty: 0 kB and Writeback: 0 kB confirm that every single block of /tmp/f has already been flushed to disk, placing 5,182,464 kB into the clean Inactive(file) LRU list. Because the Linux kernel can evict clean Inactive(file) pages in microseconds whenever a guest process requests RAM, Linux counts all 5.18 GB of that cache inside MemAvailable: 29,812,440 kB (28.4 GiB available). Consequently, no internal Linux memory pressure watermark is ever crossed, while Hyper-V sees 6,972.2 MB of touched guest physical pages.

Terminal output of /proc/meminfo inside WSL 2 showing Inactive(file) at 5,182,464 kB and Dirty at 0 kB while VmmemWSL holds 6,972.2 MB
Inspecting /proc/meminfo 70 seconds after dd finished confirms Dirty: 0 kB and Inactive(file): 5,182,464 kB: Linux counts those clean cached pages toward MemAvailable (29.8 GB), but Hyper-V still bills the full 6,972.2 MB to VmmemWSL on the Windows host.

This guest-versus-host accounting gap also explains the numbers displayed in the bottom status bar of Docker Desktop on Windows 11. When you run Docker Desktop on the WSL 2 backend, its bottom footer counter (RAM 5.99 GB | CPU 0.06% | Disk: 10.57 GB used) does not sum the isolated memory.current cgroup usage of your active containers; instead, it reports memory committed inside the shared WSL 2 utility VM, including retained Linux VFS page cache. In addition, if you open Settings > Resources > Advanced inside Docker Desktop on Windows 11, you will notice that the traditional CPU, Memory, and Swap sliders are absent. Docker Desktop explicitly states that because you are using the WSL 2 backend, resource limits are managed by Windows through a .wslconfig file, while stopping all containers triggers Resource Saver mode after 7 minutes.

Docker Desktop Settings Resources Advanced view on Windows 11 showing WSL 2 .wslconfig delegation and footer RAM transitions from 5.99 GB to 1.94 GB and 0.00 GB
Docker Desktop Settings > Resources > Advanced on Windows 11 delegates memory caps to %UserProfile%\.wslconfig, while its footer RAM counter drops from 5.99 GB to 1.94 GB when /tmp/f is deleted and reaches 0.00 GB seven minutes after the last container stops.

Before testing .wslconfig settings, we verified what happens when the file backing those cached pages is deleted inside Linux. In Linux's Virtual File System (VFS), cached page frames in the address_space radix tree (XArray in kernel 6.6) are tied to the file's underlying inode. As long as /tmp/f exists on the container's filesystem (even if no process has an open file descriptor to it) the kernel preserves its clean pages in Inactive(file) to accelerate future reads. However, the moment you unlink that inode with rm /tmp/f and its open reference count reaches zero, the kernel immediately invalidates and frees every page frame attached to that inode without touching any other container's memory or requiring a VM restart. When files must remain on disk (such as persistent database volumes or build caches), you instead rely on autoMemoryReclaim=gradual or vm.drop_caches=3.

VS Code editor showing the shell commands to write a 4 GB file with dd, inspect /proc/meminfo Cached kB, and release the page cache via rm /tmp/f
Unlinking a temporary 4 GB file (rm /tmp/f) invalidates its VFS inode mappings and immediately drops Cached memory from 5,394,408 kB to 1,200,104 kB without requiring a VM restart.

Running rm /tmp/f inside the container in Stage 7 of Test 1 confirmed this inode-unlink behavior immediately across all three telemetry layers. In the container shell, grep -E 'MemT|^Cach' /proc/meminfo showed Cached dropping from 5,394,408 kB (5.14 GiB) down to 1,200,104 kB (1.14 GiB), releasing exactly 4,194,304 kB (4.00 GiB) of page frames in 0.18 seconds. Simultaneously, Docker Desktop's bottom footer bar dropped from RAM 5.99 GB to RAM 1.94 GB at 0.00% CPU, and Windows 11 Task Manager showed VmmemWSL dropping from 6,916.8 MB (55% host memory) back to 2,694.8 MB (48% host memory). This proves beyond doubt that the extra 4.22 GB held in VmmemWSL during Stages 5 and 6 was 100% file-backed Linux page cache rather than a container or Hyper-V memory leak.

Side-by-side comparison after running rm /tmp/f showing Cached memory down to 1,200,104 kB, Docker Desktop RAM at 1.94 GB, and Windows Task Manager VmmemWSL back at 2,694.8 MB
Removing /tmp/f inside the container reduced Linux Cached memory from 5,394,408 kB to 1,200,104 kB (1.14 GiB), lowered Docker Desktop's RAM readout to 1.94 GB, and dropped VmmemWSL in Task Manager from 6,916.8 MB back to 2,694.8 MB.

Test 2: three .wslconfig conditions, polled every 30 seconds

In real development workflows, you rarely delete your newly pulled Docker image layers, compiled node_modules trees, or database files after every command, so the files remain on disk and their page cache stays resident. To measure how Microsoft's .wslconfig settings govern retained page cache over time, we automated a second experiment across three configurations, polling both Windows VmmemWSL working set and Linux free -m every 30 seconds for 10 full minutes (600 seconds) after writing a 2 GiB (2,147,483,648 bytes) file that remained on disk:

  • Condition A (No .wslconfig): Default 50% host ceiling (free -m total = 30,910 MB) and default dropCache behavior.
  • Condition B ([wsl2] memory=4GB): Hard VM memory ceiling (free -m total = 3,914 MB) without [experimental] flags.
  • Condition C ([wsl2] memory=4GB + [experimental] autoMemoryReclaim=gradual): Combines the 3,914 MB ceiling with background gradual cache reclamation.
Time-series chart from 0s to 600s comparing VmmemWSL and buff/cache under Condition A (no .wslconfig) versus Condition C (memory=4GB and autoMemoryReclaim=gradual)
Ten-minute (600-second) polling trajectories after a 2 GiB file write: without .wslconfig (Condition A), buff/cache stayed flat at 3,364 MB for 570 seconds before dropping at once, whereas memory=4GB with autoMemoryReclaim=gradual (Condition C) kept VmmemWSL under 3,995 MB and reduced cache by ~90 MB every 30 seconds.

While automating the docker exec file-write step from Git Bash (MSYS2) on Windows 11, our first pass failed across all three conditions with dd: can't open '/Device/Null': No such file or directory. Git Bash's POSIX-to-Windows path converter automatically rewrote the Linux argument if=/dev/zero into the Windows NT path if=/Device/Null before passing the command string to docker.exe. Prefixing the command with MSYS_NO_PATHCONV=1 disabled path conversion and allowed the 2 GiB write to complete at 1.6–1.9 GB/s.

Elapsed Time After 2 GiB WriteCondition A: No .wslconfig (VmmemWSL / buff/cache)Condition B: memory=4GB (VmmemWSL / buff/cache)Condition C: 4GB + gradual (VmmemWSL / buff/cache)
Baseline (t = 0s before dd)2,482 MB / 1,186 MB2,050 MB / 1,210 MB2,076 MB / 1,264 MB
After 2 GiB Write (t = 0s)4,585 MB / 3,286 MB3,988 MB / 3,120 MB3,995 MB / 3,125 MB
t = 180s (3.0 minutes)4,712 MB / 3,364 MB3,982 MB / 3,120 MB3,841 MB / 3,011 MB (-114 MB)
t = 360s (6.0 minutes)4,730 MB / 3,364 MB3,978 MB / 3,120 MB3,226 MB / 2,395 MB (-730 MB)
t = 570s (9.5 minutes)4,714 MB / 3,364 MB3,975 MB / 3,120 MB2,618 MB / 1,810 MB (-1,315 MB)
t = 600s (10.0 minutes)1,684 MB / 327 MB (Cliff drop)1,890 MB / 410 MB (Cliff drop)2,547 MB / 1,737 MB (-1,388 MB steady)
Comparison matrix of Test 2 metrics across Condition A, Condition B, and Condition C showing VM memory totals, 2 GiB allocation recovery, and 2 GiB file cache trajectories
Side-by-side empirical matrix across Condition A (no .wslconfig), Condition B (memory=4GB), and Condition C (memory=4GB + autoMemoryReclaim=gradual), including the MSYS_NO_PATHCONV=1 fix required when invoking docker exec dd from Git Bash on Windows.

The raw 600-second polling log from Test 2 exposes the exact behavioral difference between Condition A and Condition C. In Condition A (19:59:48, no .wslconfig), writing the 2 GiB file raised VmmemWSL from 2,482 MB to 4,585 MB and buff/cache from 1,186 MB to 3,286 MB. From t = 90s all the way through t = 570s (9.5 minutes), buff/cache stayed completely flat at 3,364 MB and VmmemWSL hovered between 4,698 MB and 4,731 MB, before dropping in a single cliff step to 327 MB (VmmemWSL = 1,684 MB) at t = 600s. By contrast, in Condition C (20:10:14, [wsl2] memory=4GB + [experimental] autoMemoryReclaim=gradual), VmmemWSL peaked at 3,995 MB (strictly honoring the 4 GB ceiling) and began shrinking buff/cache between t = 90s and t = 180s (3,125 MB to 3,011 MB), shedding roughly 90 MB every 30 seconds down to 1,737 MB (VmmemWSL = 2,547 MB) at t = 600s.

Retina terminal log showing 600-second VmmemWSL and free -m polling output for Condition A (no .wslconfig) and Condition C (memory=4GB and autoMemoryReclaim=gradual)
Captured 600-second polling log comparing Condition A (no .wslconfig, where buff/cache remained at 3,364 MB until dropping to 327 MB between 570s and 600s) against Condition C (memory=4GB and autoMemoryReclaim=gradual, where buff/cache stepped down every 30 seconds from 3,125 MB to 1,737 MB).

Reading VmmemWSL and buff/cache yourself

Before applying a permanent memory ceiling on your own workstation, run a one-line cross-boundary check from Windows PowerShell to compare what Windows Task Manager bills to vmmemWSL against what the Linux kernel inside WSL 2 reports for used heap versus buff/cache. We also ingested all six benchmark stages into OpenObserve v0.14.2 (stream wsl2_vmmem_telemetry on http://127.0.0.1:5080) to correlate proc_cached_kb, vmmemwsl_mb, and wsl_buff_cache_mb across all three .wslconfig profiles:

# PowerShell 7.4 - Compare Windows Host VmmemWSL Working Set with Linux free -m
$vmmemMB = [math]::Round((Get-Process vmmemWSL -ErrorAction SilentlyContinue).WorkingSet64 / 1MB, 1)
Write-Host "Windows Host vmmemWSL Working Set: $vmmemMB MB" -ForegroundColor Cyan
wsl -d docker-desktop -- free -m

If used in free -m is high and growing, an active container is consuming heap memory (see our Docker Exit Code 137 OOMKilled diagnostic guide). If used is low (for example, under 1,000 MB) while buff/cache accounts for multiple gigabytes, you are looking at retained VFS page cache, the exact same Linux MemAvailable vs page-cache distinction required when monitoring unified-memory AI boxes (see our NVIDIA GB10 MemAvailable and page-cache reclaim fixes).

Live OpenObserve v0.14.2 Logs Explorer at http://127.0.0.1:5080 displaying the wsl2_vmmem_telemetry stream across Test 1 and Test 2 .wslconfig stages
Auditing all six WSL 2 page-cache and .wslconfig telemetry stages in OpenObserve v0.14.2 (http://127.0.0.1:5080, stream wsl2_vmmem_telemetry): correlating proc_cached_kb, vmmemwsl_mb, and wsl_buff_cache_mb in 10 ms.

Capping WSL memory with .wslconfig

Write %UserProfile%\.wslconfig

To prevent vmmemWSL from claiming up to 50% of your physical RAM while enabling automatic background page-cache decay, create or edit %UserProfile%\.wslconfig in your Windows user home directory (for example, C:\Users\hun\.wslconfig) by pressing Win + R and running notepad %UserProfile%\.wslconfig. Make sure you place memory, processors, and swap under the [wsl2] section header, and place autoMemoryReclaim=gradual and sparseVhd=true under the [experimental] section header. Use the following host RAM sizing table to choose the right memory cap for your workstation so both Windows 11 and your Docker containers have sufficient headroom:

Windows 11 Host RAMRecommended [wsl2] memory CapRecommended processors & swapExpected free -m total Inside WSL 2
16 GB Host RAMmemory=4GB (or 6GB)processors=4, swap=2GB~3,914 MB (Reserves 10–12 GB for Windows)
32 GB Host RAMmemory=8GB (or 12GB)processors=6, swap=4GB~7,828 MB (Balanced for Docker + IDE)
64 GB+ Host RAMmemory=16GB (or 24GB)processors=8, swap=8GB~15,656 MB (Stops 30.9 GB default cache bloat)
VS Code split editor showing %UserProfile%\.wslconfig and the PowerShell script pairing Get-Process vmmemWSL with wsl -d docker-desktop -- free -m
Production %UserProfile%\.wslconfig pairing [wsl2] resource caps (memory=4GB, processors=4, swap=4GB) with [experimental] autoMemoryReclaim=gradual and sparseVhd=true, alongside the PowerShell diagnostic script used to verify both sides of the VM boundary.

Restart with wsl --shutdown (and the 8-second rule)

Saving %UserProfile%\.wslconfig has zero effect on an already running WSL 2 utility VM because the Windows WSL service only parses .wslconfig during a cold VM boot. Microsoft's official WSL documentation also specifies the "8-second rule": after closing all Linux shells or running wsl --shutdown, you must wait at least 8 seconds for the Hyper-V utility VM subsystem to completely unload before starting a distribution again. In our Test 2 measurements, when Docker Desktop was left open on the Windows host during wsl --shutdown, Docker Desktop detected the VM termination, waited for the subsystem reset, and automatically restarted the WSL 2 backend so that docker info succeeded again within 11 to 12 seconds. Run the following sequence in PowerShell to apply your new configuration and confirm that free -m reports total = 3914 (for memory=4GB):

# Shut down the WSL 2 utility VM, honor the 8-second rule, and verify the new ceiling
wsl --shutdown
Start-Sleep -Seconds 8
wsl -d docker-desktop -- free -m
Split comparison before and after wsl --shutdown showing free -m total dropping from 30,910 MB (no .wslconfig) to 3,914 MB (memory=4GB)
Shutting down WSL (wsl --shutdown) and waiting 8 seconds lowers the Linux VM's reported free -m total from 30,910 MB to 3,914 MB, clamping VmmemWSL below 4,000 MB while Docker Desktop reconnects automatically within 11 to 12 seconds.

Dropping the page cache on demand

Even with autoMemoryReclaim=gradual shrinking idle page cache by ~90 MB every 30 seconds after 2.5 minutes, there are times when you finish a massive docker build, database restore, or multi-gigabyte archive extraction and want several gigabytes of host RAM returned to Windows 11 in under a second without stopping your running containers. You can trigger an immediate kernel VFS cache flush inside WSL 2 by writing to /proc/sys/vm/drop_caches after calling sync to flush any dirty buffers to disk. Writing 1 frees clean pagecache, writing 2 frees reclaimable slab objects (dentries and inodes), and writing 3 flushes both pagecache and dentries/inodes simultaneously in 0.34 seconds:

# Flush clean pagecache, dentries, and inodes immediately (safe for running containers)
sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"

# Optional: Add a persistent 'dropmem' alias to ~/.bashrc or ~/.zshrc
echo 'alias dropmem="sudo sh -c '''sync; echo 3 > /proc/sys/vm/drop_caches''' && free -m"' >> ~/.bashrc
Benchmark chart comparing time-to-reclaim and freed RAM across default dropCache (570s), autoMemoryReclaim=gradual (90 MB per 30s), rm file unlink (0.18s), and sysctl vm.drop_caches=3 (0.34s)
Comparing the four ways to release WSL 2 page cache: automatic dropCache waited 570 seconds in our test, autoMemoryReclaim=gradual reclaimed ~90 MB every 30 seconds after 2.5 minutes, and manual sync; echo 3 > /proc/sys/vm/drop_caches flushes clean cache on demand in under 0.4 seconds.

Compacting ext4.vhdx (disk space, not RAM)

Developers troubleshooting VmmemWSL often conflate physical host RAM with virtual hard disk space on their Windows NVMe SSD. Every WSL 2 distribution (and Docker Desktop's docker-desktop-data volume store) resides inside a dynamically expanding Hyper-V virtual hard disk file named ext4.vhdx under %LocalAppData%\Packages\...\LocalState\ or %LocalAppData%\Docker\wsl\disk\. When you write 4 GB with dd and then run rm /tmp/f, the Linux kernel immediately frees the 4 GB of RAM page cache in VmmemWSL, but the ext4.vhdx file on your Windows NTFS drive stays at its expanded size until compacted. Adding sparseVhd=true under [experimental] enables automatic sparse block trimming on newly created VHDs; to shrink an existing ext4.vhdx file offline, run an elevated PowerShell prompt:

# Compact an existing WSL 2 or Docker Desktop ext4.vhdx virtual disk (Run as Administrator)
wsl --shutdown
diskpart
# Inside diskpart prompt:
select vdisk file="C:\Users\hun\AppData\Local\Docker\wsl\disk\docker_data.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
exit
System architecture diagram showing how Windows 11 VmmemWSL RAM is governed by .wslconfig and Linux page cache reclamation while ext4.vhdx disk space is compacted via diskpart
End-to-end WSL 2 resource architecture distinguishing host RAM held in the Linux kernel page cache (governed by [wsl2] memory, [experimental] autoMemoryReclaim=gradual, and vm.drop_caches=3) from physical NVMe disk blocks allocated inside ext4.vhdx (compacted offline via diskpart).

Verification Checklist

After deploying %UserProfile%\.wslconfig and restarting WSL 2, run through these three verification gates to confirm your workstation is protected against both unbounded page-cache growth and silent configuration errors. If your Windows 11 PC still shows 95%–100% RAM usage while vmmemWSL is under 4 GB, inspect the Windows kernel Non-Paged Pool instead using our Windows 11 Non-Paged Pool & Ndu.sys Memory Leak Guide. For container networking and health probe issues after a WSL restart, see our Docker Windows 11 ECONNREFUSED 127.0.0.1 Fix and Docker Compose Healthcheck Failures Guide:

  1. Guest Ceiling Gate: Run wsl -d docker-desktop -- free -m and confirm Mem: total matches your [wsl2] memory cap (3914 MB for memory=4GB, down from 30910 MB).
  2. Host Working Set Gate: Run Get-Process vmmemWSL during a 2 GiB file write and confirm WorkingSet64 never exceeds your configured ceiling (<= 3,995 MB).
  3. Gradual Reclaim Gate: Poll free -m every 30 seconds after file I/O stops and verify buff/cache begins stepping down by ~90 MB every 30 seconds after 2.5 to 3 minutes.
Decision tree and host RAM sizing matrix for troubleshooting high VmmemWSL memory usage on Windows 11 with .wslconfig, autoMemoryReclaim=gradual, drop_caches, and diskpart
Diagnostic decision tree and host RAM sizing matrix for isolating VmmemWSL page cache retention, applying [wsl2] memory caps and [experimental] autoMemoryReclaim=gradual across 16 GB, 32 GB, and 64 GB Windows 11 workstations, and verifying the 3,914 MB ceiling after wsl --shutdown.

Summary

  • Confirm the Process Name First: vmmemWSL is the shared WSL 2 and Docker Desktop utility VM; a separate Vmmem row (1,036.1 MB on our PC) belongs to non-WSL Hyper-V or Windows Sandbox workloads.
  • Heap Frees Automatically, Page Cache Does Not: In Test 1, a 4 GB Python bytearray returned 3,955.5 MB to Windows immediately upon process exit, whereas a 4 GB dd file write locked 5,394,408 kB in Linux Cached memory (holding vmmemWSL at 6,916.8 MB) until the file was unlinked (rm /tmp/f -> 2,694.8 MB).
  • Combine [wsl2] memory with [experimental] autoMemoryReclaim=gradual: In Test 2's 600-second polling benchmark, pairing memory=4GB with autoMemoryReclaim=gradual clamped vmmemWSL below 3,995 MB and smoothly reclaimed ~90 MB every 30 seconds after 2.5 minutes, while sync; echo 3 > /proc/sys/vm/drop_caches flushes clean cache on demand in 0.34 seconds.

WSL2 VmmemWSL Page Cache & .wslconfig Reclaim Q&A

Why stays VmmemWSL memory high in Task Manager after my Docker container exits?

The Linux kernel inside the WSL 2 utility VM caches disk reads and writes in VFS page cache (buff/cache) even after processes terminate. In our 4 GB file write test, VmmemWSL retained an extra 4.1 GB until the file inode was unlinked or memory limits reclaimed clean pages.

Does autoMemoryReclaim=gradual work without rebooting WSL 2?

No. Edits to %UserProfile%\.wslconfig only take effect after running wsl --shutdown in PowerShell and waiting at least 8 seconds for the Hyper-V utility VM to terminate completely before restarting Docker Desktop or Ubuntu.

Why did my ext4.vhdx file stay large on disk after freeing VmmemWSL RAM?

Reclaiming Linux page cache frees physical host RAM in VmmemWSL, whereas virtual hard disk blocks inside ext4.vhdx stay allocated on NTFS until trimmed. Enable sparseVhd=true in .wslconfig or compact ext4.vhdx offline after shutting down WSL.

100% Client-Side Utilities · Printable A4 Runbook

Run Prefilled Sizing Math & Download the 1-Page Runbook

Size Docker container RAM inside your WSL2 .wslconfig memory cap and compute 4K/5K2K workstation framebuffer memory.

Paired Prefilled Calculators & Vector PDF Checklist

Yun Sanghun (M. Yun) · Linux, Docker & AI Infrastructure Engineer