wslc container cp completely fills RAM
Windows Version
10.0.19044.7548
WSL Version
2.9.4.0
Are you using WSL 1 or WSL 2?
- [x] WSL 2
- [ ] WSL 1
Kernel Version
No response
Distro Version
Debian
Other Software
No response
Repro Steps
Create a container
Copy a large directory (50 GB+) from a high-speed SSD to a slower SSD using wslc container cp:
wslc container cp D:/Gauthier/Downloads/ComfyUI/models comfy_ui:/ComfyUI/ (in my case)
Expected Behavior
The copy operation should complete without consuming all available RAM. The copy operation should not create temporary files, as this wastes time and doubles the required disk space during the copy.
Actual Behavior
Vmmem uses up to 16 GB of RAM during the copy operation and does not release the memory after the copy has finished.
Diagnostic Logs
Before RAM usage increases :
After the temporary files have been written:
After CP is finished :
Logs are required for review from WSL team
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1
The script will output the path of the log file once done.
If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues
Once completed please upload the output files to this GitHub issue.
See Collect WSL logs (recommended method).
If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.
Logs are required for review from WSL team
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1
The script will output the path of the log file once done.
If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues
Once completed please upload the output files to this GitHub issue.
See Collect WSL logs (recommended method).
If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.
Diagnostic information
appxpackage.txt not found
Reproduced the same signature on 2.9.4.0 (Windows 11 22H2+, Vmmem climbing to ~15-16GB on a ~40GB copy and not dropping back after the copy finishes). A few observations that might help:
The "not releasing after finish" part is partly WSL2's memory policy, not necessarily a leak. The Vmmem process retains freed pages for caching rather than returning them to Windows (this is the normal behaviour WSL2 exhibits after heavy I/O). The reliable way to force release is wsl --shutdown and restart the VM. A good diagnostic: after the copy, run wsl --shutdown, restart, and see whether Vmmem stays high on idle — if it comes back down, the growth was cache pressure rather than a committed leak. If it does come back down, that points to the peak (not the retention) being the real problem.
The 16GB peak during copy is the more suspicious part. wslc container cp from a Windows path into a container has to move data across the VM boundary, and a naive implementation can buffer a large window (or materialise temp files, as you noted) instead of streaming. The fact that it also writes temp files (doubling disk) suggests the copy path is staging in the guest before landing in the container — which would explain both the RAM spike and the extra disk.
Workarounds until fixed:
- Stream in chunks rather than one big cp — e.g.
wslc container execwith a tar pipe (tar -C models . | wslc container exec -i comfy_ui tar -xC /ComfyUI/) keeps memory flat because tar streams. - If the mount path supports it, bind-mount the Windows directory into the container and let VirtioFS handle reads instead of copying — no RAM spike, no temp files.
I have a write-up on wslc storage/performance (including the VirtioFS vs 9p throughput difference and streaming patterns) at https://wslcontainers.com/guides/volumes/ — will add a note about large-copy memory behaviour and the tar-stream workaround when this is resolved.
For the WSL team: the key question is whether container cp can be made to stream (or at least bound its staging window), and whether temp-file staging can be avoided for the Windows→guest direction.
I believe the memory remaining elevated after the copy should be addressed by microsoft/WSL#41096 and microsoft/WSL#41171. These changes correct guest idle detection and reclaim cached filesystem memory sooner after workloads finish.
Please update to WSL 3.0.3 or later and retry the copy, allowing a few minutes of guest inactivity afterward.
The temporary archive is a separate issue and is not removed by these changes. Memory may still grow during the copy because Linux caches the extracted files; the expected improvement is that it is reclaimed afterward.