How to Increase or Reduce WSL 2 RAM Limit in Windows 11 (.wslconfig Guide)

Oct 29, 2026
By Admin
3 min read
75 views
How to Increase or Reduce WSL 2 RAM Limit in Windows 11 (.wslconfig Guide)

How to Increase or Reduce WSL 2 RAM Limit in Windows 11 (.wslconfig Guide)

By default, WSL 2 allocates 50% of your total system RAM (~15.3 GB on a 32 GB system). To increase or reduce it (for example, increasing it to 24 GB), create a .wslconfig file in your Windows user profile directory and restart WSL.


Option 1: Using .wslconfig (Quickest)

Create the config file at C:\Users\Dan Ong'udi\.wslconfig (or your Windows $env:USERPROFILE\.wslconfig path) by running this command in PowerShell:

@"
[wsl2]
memory=24GB
"@ | Set-Content "$env:USERPROFILE\.wslconfig"

Or open Notepad, paste the two lines below, and save it as C:\Users\Dan Ong'udi\.wslconfig:

[wsl2]
memory=24GB

Restart WSL from PowerShell or Command Prompt so the change takes effect:

wsl --shutdown

Reopen your WSL terminal and run htop or free -h — Mem will now show ~24 GB:

free -h
# or launch interactive process viewer
htop

Option 2: Using the WSL Settings GUI (Windows 11)

  1. Open the Windows Start Menu and search for WSL Settings.
  2. Go to Memory and processor → Memory size and set it to 24576 MB (24 GB).
  3. Run wsl --shutdown in PowerShell and reopen WSL.

What Happens If You Set WSL 2 RAM to 32 GB on a 32 GB PC?

If your PC has 32 GB of physical RAM in total, setting memory=32GB won't immediately break anything on startup, because memory in .wslconfig is a maximum ceiling, not an upfront reservation — WSL only takes RAM as it needs it.

However, if a workload inside WSL actually tries to use near 32 GB, your entire PC will freeze or crash:

  • Windows gets starved of RAM: Windows 11 itself needs at least 4–6 GB of RAM just to run the OS, desktop UI, and background services (plus ~1.4 GB is already hardware-reserved, which is why 50% of your RAM showed as 15.3G instead of 16.0G).
  • Severe system stuttering (Swap Thrashing): As WSL crosses ~25–27 GB of usage, Windows is forced to push its own system processes and open apps (like your browser or IDE) onto your SSD's pagefile.sys. Your mouse cursor, audio, and windows will stutter or lock up completely.
  • Abrupt WSL or Windows crashes: Normally, if a Linux process uses too much RAM, the Linux Out-Of-Memory (OOM) killer cleanly stops just that process. If you set the limit to 32 GB, Linux thinks it still has free room while Windows physically runs out of memory first — causing Windows to forcefully terminate your entire WSL VM (losing unsaved work) or crash Windows apps.
  • Linux file cache won't let go early: Linux uses "unused" RAM up to its limit to cache disk files. With a 32 GB cap, heavy disk operations in WSL will slowly eat up all available host RAM for caching until Windows starts choking.

Rule of Thumb for a 32 GB Machine

  • 24 GB (memory=24GB) is the sweet spot — it gives WSL plenty of headroom while leaving ~8 GB so Windows and your IDE/browser stay snappy.
  • 26 GB (memory=26GB) is the practical safe maximum if you keep very few Windows apps open.
Physical Host RAM Default WSL 2 Ceiling (50%) Recommended Sweet Spot Practical Safe Maximum
16 GB ~7.6 GB 10GB 12GB
32 GB ~15.3 GB 24GB 26GB
64 GB ~31.2 GB 48GB 54GB

Pro Tip: Automatic Memory Reclamation

💡 TIP: You can also add automatic memory reclamation to .wslconfig so WSL hands unused cached RAM back to Windows automatically.

[wsl2]
memory=24GB

[experimental]
autoMemoryReclaim=gradual
Share this article:
Back to Blog

More Engineering Articles

View All

Ready to Engineer Scalable Systems for Your Enterprise?

Our engineering team builds custom ERPs, ISP billing platforms, fintech automation, and cloud architectures tailored to your business.

Get in Touch