WSL (Windows Subsystem Linux)

This depends on the version of WSL that you are using:

  • In WSL1, linux applications run alongside other windows applications, memory and CPU are only used when you run linux applications.
  • In WSL2, applications run on a lightweight virtual machine, there is an amount of memory and CPU is assigned to the virtual machine

WSL1

Memory: if you are not running a Linux program, the WSL does not use any memory or starts any process.

  • The first time you start a linux window, one or more init processes are started. In my Windows 10 with Ubuntu 18.04, it occupies 0.1MB in RAM and, typically, 0% of CPU.
  • The console starts multiple processes: some console windows processes, a WSL background host, an some linux launchers. In my test, all these processes occupy 13.3MB in RAM.
  • Each time you run a linux program, it will occupy the corresponding memory and CPU percentage.
  • After you close all the consoles and linux processes, all these processes are killed.

Disk space: the space occupied by the WSL vary depending on the Linux distributions you install in your computer. Currently, it is possible to install multiple distributions: e.g., Ubuntu 20, Opensuse and Kali Linux. In fact, you can create your own distributions.

When you install a Linux distribution from the Windows app store, a linux launcher is installed. The first time you run the program, it downloads a compressed file with the distribution and unpacks that file.

  • The disk space occupied by WSL depends on the linux distribution you are used.
  • Usually, the compressed file is not deleted. Then, you must consider the size of the compressed file and of the distribution filesystems.

Considering the Ubuntu distributions that you can get from Microsoft.

  • Ubuntu 14: the 14.04.5.3-server-cloudimg-amd64-root.tar.gz compressed file occupies 182MB. After decompression, it is 255MB approx.
  • Ubuntu 16: the 16.04.2-server-cloudimg-amd64-root.tar.gz file occupies 226MB. It is 672MB approx after decompression.

You may check other distributions compressed files from the LxRunOffline wiki.


WSL2

Memory: Normally, WSL2 consumes the 50% of the total memory on Windows or 8GB whichever is less (Before Windows version 20175, 80% of your total memory). However, you can configure a limit for the memory to assign in the .wslconfig file.

For instance, you can limit the memory and the processors in the %UserProfile%\.wslconfig using the following:

[wsl2]
memory=4GB # Limits VM memory in WSL 2 to 4 GB
processors=2 # Makes the WSL 2 VM use two virtual processors

Disk space: Usually, after installing WSL2, your virtual machine uses 1.92 GB.

  • You may check the disk consumption in Windows in Apps & Features under the WSL2 item.
  • You can use commands in linux to determine the disk usage. For instance, you can run ncdu --exclude /mnt to check the space used by the linux filesystems.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *