skip to Main Content

I created a .wslconfig file following the first answer here to limit wsl resource consumption on my Win10 os. It does not work and I have no clue why. I am using Docker Desktop. File:

# Limit the wsl or vmmem consumption of resources

[wsl2]
memory=3GB # Limits VM memory in WSL 2 to 3 GB
processors=3 # Makes the WSL 2 VM use 3 virtual processors
localhostForwarding=true # Boolean specifying if ports bound to wildcard or localhost in the WSL 2 VM should be connectable from the host via localhost:port.
  • I am using windows build 19042.1526, which should be able to handle such file
  • The file itself is actually a .wslconfig and not an accidental .txt
  • I have restarted my PC and used Restart-Service LxssManager in my admin powershell successfully
  • I am actually using WSL 2
  • I saved the file in C:UsersPC Paul which is the main user

I am at my wits end, do you have any idea where the problem might be?

Thanks,
Paul

3

Answers


  1. Chosen as BEST ANSWER

    Ok it seems like the file has to start with [wsl2]. I deleted the comment at the top and now it seems to work.

    Edit: Further help if it doesn't work may be found here: https://superuser.com/questions/1632543/wslconfig-not-applied-for-wsl2


  2. In my case, it turns out that the memory parameter is case sensitive. I.e. you have to use GB, not Gb. E.g. this works…

    [wsl2]
    memory=3GB
    

    This doesn’t work…

    [wsl2]
    memory=3Gb
    
    Login or Signup to reply.
  3. In my case I created the .wslconfig file by creating a new file like this:

    enter image description here

    After saving it the icons displayed was this:

    enter image description here

    I thought it should work because the name is correct.
    But when I open the userprofile folder in command prompt and type in dir
    it showed .wslconfig.txt

    Solution:
    Open command prompt, change directory and then rename file manually

    cd %userprofile% 
    rename .wslconfig.txt .wslconfig
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search