SWAP in wsl-container
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
**Is your feature request related to a problem? Please describe.**
WSLC creates a separate swap.vhdx for every WSLC session, and the swap size is currently tied directly to the session's configured memory size. There is no user-facing option to disable or configure this swap.
This is problematic for workloads where swap is undesirable or unnecessary, such as Docker/container workloads where predictable memory usage and strict memory limits are preferred. Even when swap is not needed, WSLC still creates and enables it automatically.
This behavior is also different from regular WSL2, where swap can be explicitly disabled with swap=0 in `.wslconfig`.
**Describe the solution you'd like**
Please provide a WSLC configuration option to control the session swap size (`settings.yaml`), for example:
```
session:
...
swapSize: 0
```
OR turn off it by default.
**Describe alternatives you've considered.**
Maybe you'll provide a WA, like `swapoff -a` , cuz I tried, but it required superuser permission (though I did from root user):
```
root@8aa0065a7778:/app# swapoff -a
swapoff: Not superuser.
```
**Additional context**
The relevant session storage is located under:
`%LOCALAPPDATA%\wslc\sessions\\`
I think it can expand dynamically, please correct me if I'm wrong.
```
root@8aa0065a7778:/app# swapon -s
Filename Type Size Used Priority
/dev/sdd partition 33515516 0 -2
```
Contributor guide
Research direction
Start by locating the session configuration in settings.yaml and the session storage under %LOCALAPPDATA%\wslc\sessions\\. Trace how the configured memory size leads to swap.vhdx creation and verify the result with swapon -s; done means the requested swap size can be configured, including zero, or the default behavior is changed as agreed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- yaml
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100