andrew17
andrew17

Reputation: 925

How to check allocated memory for WSL Docker?

I want to increase allocated RAM for WSL. I have created in my root /users/ .wslconfig. How does it looks:

[wsl2]
memory=6GB
swap=0
localhostForwarding=true

I did wsl --shutdown and then started WSL to apply changes. But I don't know how to check if allocated RAM is changed. How do I check it?

Upvotes: 19

Views: 45314

Answers (2)

andrew17
andrew17

Reputation: 925

In Docker Desktop CLI you can type cat /proc/meminfo to check Docker memory usage.

Upvotes: 2

cam
cam

Reputation: 5228

One way you can check is from inside the WSL2 environment with standard Linux commands. See which WSL environments you have by running this in Powershell: wslconfig /list and if you have WSL2 properly configured, you can access the shell with wsl also in Powershell.

$ free -mh
              total        used        free      shared  buff/cache   available
Mem:          7.8Gi       552Mi       5.9Gi       400Mi       1.3Gi       6.6Gi
Swap:         2.0Gi          0B       2.0Gi

I have 16GB RAM on my machine and my wsl2 config is this:

[wsl2]
memory=8GB # Limits VM memory in WSL 2 to 8 GB

There are a handful of other commands you could use too, including:

# print memory usage statistics
$ vmstat -s

# print top processes with memory information
$ top

# fancy top
$ htop

Upvotes: 37

Related Questions