Paul1911
Paul1911

Reputation: 193

Docker consuming more resources than specified in .wslconfig

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 at my wits end, do you have any idea where the problem might be?

Thanks, Paul

Upvotes: 2

Views: 2243

Answers (3)

Jaswir
Jaswir

Reputation: 305

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

Upvotes: 1

Alan
Alan

Reputation: 1945

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

Upvotes: 0

Paul1911
Paul1911

Reputation: 193

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

Upvotes: 1

Related Questions