how to increase memory and cpu limits for wsl2 windows 11

yyurijj 10 Reputation points
2023-06-01T19:49:54.8133333+00:00

hi people! despite the fact that I changed the Windows ~.wslconfig and /etc/wsl.conf files accordingly by adding

[wsl2]

# kernel=C:\\temp\\myCustomKernel

processors = 6 # Makes the WSL 2 VM use six virtual processors

localhostForwarding = true

# Limits VM memory to use no more than 10 GB, this can be set as whole numbers using GB or MB

memory = 10GB

still see

               total used free shared buff/cache available
Mem: 7.4Gi 526Mi 6.9Gi 2.2Mi 226Mi 6.9Gi

as if these configuration file changes have no effect on anything, why?

Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
9,860 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. kwaku appiah 15 Reputation points
    2023-06-20T14:15:50.26+00:00

    First ensure that the .wslconfig file is defined in the Users folder e.g. C:/Users/yyurijj/.wslconfig
    If you have already created the file you can skip to number 3.

    1. You can use this command "notepad.exe %UserProfile%/.wslconfig" in the windows explorer address bar
      then paste the text below as the content for the file
    [wsl2]
    #Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
    memory=4GB
    #Sets the VM to use two virtual processors
    processors=4
    

    For more wsl configuration options please use this link https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconfig

    1. Save the file
    2. Run the command "wsl --shutdown" to stop the wsl service
    3. Run the command "restart-service LxssManager" in PowerShell running as administrator to restart wsl

    The trick is to ensure that you shut down and restart wsl after making changes to the config file.

    3 people found this answer helpful.
    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.