Docker and WSL: why vmmem eats your RAM and ext4.vhdx never shrinks

By the Zofle team · 6 November 2026 · 4 min read

Windows users who run Docker Desktop or WSL often see two things. Task Manager shows a process named vmmem (or vmmemWSL) taking several gigabytes of memory and a lot of CPU. And the C: drive shrinks, because a virtual disk file called ext4.vhdx keeps growing and never gets smaller. Both come from the same place: WSL 2 runs Linux in a lightweight virtual machine, and the VM is a program that keeps what it was given.

The process: vmmem and vmmemWSL

vmmem is not a real program. It is how Windows shows the memory and CPU used by the WSL 2 virtual machine, which includes every container you run in Docker Desktop. By default WSL 2 may use up to half of your RAM and all your processors. Linux uses free memory for its file cache, and that memory is not always handed back to Windows, so vmmem can stay large after your containers go idle.

Cap it. Create or edit %UserProfile%\.wslconfig:

[wsl2]
memory=6GB
processors=4
swap=2GB

[experimental]
autoMemoryReclaim=gradual
sparseVhd=true

Then run wsl --shutdown from PowerShell and start Docker again. autoMemoryReclaim and sparseVhd need a recent WSL release (check with wsl --version and wsl --update). Pick a memory cap that leaves Windows enough: half your RAM is a sensible start on a 16 GB machine.

The file: ext4.vhdx and docker_data.vhdx

WhatTypical location (varies by version)
Ubuntu or another WSL distro%LocalAppData%\wsl\{GUID}\ext4.vhdx or %LocalAppData%\Packages\<distro package>\LocalState\ext4.vhdx
Docker Desktop data (WSL backend)%LocalAppData%\Docker\wsl\disk\docker_data.vhdx (older: ...\wsl\data\ext4.vhdx)
Docker Desktop on a Mac~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw

A virtual disk grows when Linux writes to it. When you delete files inside Linux, the file on Windows normally stays the same size. That is why deleting images in Docker does not give you your C: drive back.

Clean up, in this order

  1. See what Docker holds: docker system df.
  2. Remove what is unused: docker system prune (stopped containers, unused networks, dangling images). Add -a to remove all unused images, and run docker builder prune for the build cache. docker volume prune deletes data of containers that are not running, including databases, so read the list first.
  3. Shrink the disk file: run wsl --shutdown, then either wsl --manage <distro> --set-sparse true (new WSL) or in an admin PowerShell with Hyper-V tools, Optimize-VHD -Path <file>.vhdx -Mode Full. diskpart with select vdisk file=... then compact vdisk works on Windows Home too.
  4. Back up first with wsl --export if the distro holds anything you care about.

Other things to know

  • An old distro you no longer use still holds its whole disk. wsl -l -v lists them; wsl --unregister <name> deletes one and everything in it, with no undo.
  • Keep your project files inside the Linux file system, not under /mnt/c, for speed. They then count toward the vhdx.
  • On a Mac, Docker Desktop has a disk image size limit in its Resources settings, and Docker.raw works the same way.

Where Zofle fits. Zofle is a free disk cleanup and file finder for Mac and Windows. It shows what is filling a disk, folder by folder, lists developer caches, old build folders and leftovers with their size and date, lets you untick what you want to keep, and sends the rest to the Trash or Recycle Bin first so you can undo it.

Sources and method

  • Microsoft Learn: Advanced settings configuration in WSL (.wslconfig); Manage WSL disk space.
  • Docker Docs: docker system prune, docker system df, Docker Desktop settings.
  • Paths and commands are from each tool's own documentation and can differ by version; run the 'find it' command on your own machine before deleting anything.

Zofle Pro news

People signing up now will get Zofle Pro, with more features, for free when we launch it.

One email when it's ready. No spam, ever.