Does Windows Subsystem for Linux consume resources (CPU/memory/HD) when I don't use it?

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.

I have no problem with the other answers, "linux distro app not running, no resources being used", however if you run a persistent process within the WSL linux distro app the process will continue even when the linux app is closed. eg I have WSL ubuntu 18.04 running on W10 x64 pro 1903. I have installed full lamp stack, eg apache2, mysql etc, running wordpress and drupal websites using WSL ubuntu. sudo service apache2 start runs the service and it will continue to run even if the wsl ubuntu app is closed. So to answer the original question "WSL linux distro app can continue to run processes and consume resources even when the app is closed"


The memory is used up by the Linux's file cache. You can check with the buff/cache section of the free command. To drop the cache and thus free up the RAM, do echo 3 | sudo tee /proc/sys/vm/drop_caches.

If you find doing this too often, you can limit the memory used by WSL by setting

[wsl2]
memory=512MB

in %userprofile%/.wslconfig.