Modify WSL2 memory upper limit

The memory size that WSL2 can use by default is 80% of the host. For Linux, even if the desktop is installed, there is no need to give so much memory for general development. If it is too much, it may be blocked by the Windows
operation of the host :
1. Open Windows Explorer, enter %UserProfile% in the address bar and press Enter to create a file in this directory with the name .wslconfig . The example of the written content is as follows (my computer 8GB memory, 2GB for WSL memory, and 4GB for swap partition)

[wsl2]
memory=2GB
swap=4GB
localhostForwarding=true

cmd executes wsl --shutdown to close WSL, and then reopen it

Guess you like

Origin blog.csdn.net/weixin_45579994/article/details/112386425