Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Reduce Memory (RAM) Consumes in WSL 2

June 28, 2024
in Blog, WSL
0
ADVERTISEMENT

Table of Contents

In some cases, you want to configure or limit the memory (RAM) for a WSL instance. By default, WSL will take 50% of the host memory. You can check how much memory and swap space are allocated to WSL using the free command from within a WSL distribution:

sudo free -h --giga
kIM4i9tuxyD40GGBCwivUCQZFkznsYwyVZWTUqVP1onkdijGb0FkXoAO3y2T

From the Task Manger, you can check the total of RAM that WSL is consumed by finding a process named VmmemWSL.

CiBPhPF09tCCvDFUnN3Kn6oJTP1u7X7nFEaQIsm4YwEuT5IpVcd4E9ErqhiR

Whatever the case may be, if your machine doesn’t have enough memory to begin with, then you’ve probably seen some noticeable slowdowns due to WSL 2. Your machine may become sluggish as it struggles to run resource-hungry host processes.

How to Configure Memory Limits in WSL2

You can tell WSL 2 how much RAM, swap space, CPU cores, and other resources it should allocate by creating a special .wslconfig file under your Windows user profile directory (C:\Users\YourUsername\.wslconfig). On launch, WSL will read this file if it exists and configure itself accordingly.

1. First, right click on the Windows Start icon then open an elevated PowerShell window.

CiBPhPF09tCCvDFUnN3Kn6oJTP1u7X7nFEaQIsm4YwEuT5IpVcd4E9ErqhiR

2. Run the following command to edit the WSL global configuration file using the Notepad.

notepad $home\.wslconfig

3. This is the first time you edit the file. So, it will ask you to create the file. Click Yes to create the file.

4HFfhYY3PGQJKQAughjTFVrMYQZOEdVuK6olvQxuiImNhDKsisBCKbKkHM28

4. Enter the following line then save the configuration file. We will limit the memory of WSL to 1GB. You can change it to any value as you need.

[WSL2]
memory=1GB
ak7s7doTreQDF6B5tjNZG2NtuAA89bi9Us6JE5TwxkbUVrGiX31AMpJHlCwR

5. You can either close out of WSL manually and wait a few seconds for it to fully shut down, or you could launch Command Prompt or PowerShell and run the following command to forcibly shut down all WSL distributions:

wsl --shutdown

Relaunch your WSL distribution when the above command finishes executing.

wsl -d ubuntu

6. Finally, run the free command again to verify that WSL respects your specified resource limits. As you can see, the memory of the WSL instance is limited to 1GB.

tVscHpuNi6LxR6OXEAIzYqxVSVf7bqrIlK32DTNkd4mkqiu8B8goy6jm8W3f
yWDyA6isxfPz2F4hKoFjHRmA4QyTTN4n7v82wxRSv1J41F1ER50r8Rw7NQ2R
ADVERTISEMENT

Not a reader? Watch this related video tutorial:

5/5 - (1 vote)
Previous Post

How to Hide All Rights Reserved Message in CMD Command Prompt

Next Post

How to Export and Import Putty Settings to Another Computer

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory