16

I need Linux tools to simplify my life as a developer, and to connect effortlessly to remote Linux servers. I would like to install the Windows Subsystem for Linux (with Ubuntu distro) but my laptop is already struggling with the current apps. My system:

OS :Windows 10 Pro x
Version :9200 Manufacturer :HP Model :HP EliteBook Folio 1040 G3 Total Memory :System.Windows.Forms.Label, Text: 8072 MB Processor: Intel Core i7-6600U @ 2.60 Ghz (2 cores, 4 logical processors)

My problem is that I have so much stuff running in the background (installed by my laptop's administrators) that even with just:

  • Sublime Text
  • Chrome (4 tabs, not 40)
  • Slack
  • Skype for Business
  • Outlook

I'm already at 18% CPU occupation and 86% memory occupation.

Question: if I install Windows Subsystem for Linux as detailed here https://docs.microsoft.com/en-us/windows/wsl/install-win10 will it consume further resources, even if I don't use it? Or will it consume them only when I open a bash shell?

4
  • 1
    WSL is a UWP application. If you don't have the application then it does not consume resources.
    – Ramhound
    Commented Feb 27, 2018 at 15:28
  • @Ramhound thanks a lot and pardon my ignorance: when you say "If you don't have the application", you mean if I don't have it open. Right?
    – DeltaIV
    Commented Feb 27, 2018 at 15:47
  • 2
    If you don't have the application running, then it doesn't and cannot, consume system resources.
    – Ramhound
    Commented Feb 27, 2018 at 17:17
  • @Biswapriyo thanks for the interest. I haven't still installed it - I was thinking to do that. Right now I've done step 1 & 2 on this page. I was thinking to install Ubuntu from the Windows Store. Do you think it's a good idea?
    – DeltaIV
    Commented Mar 6, 2018 at 18:07

3 Answers 3

21

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.
2
  • 1
    In the meantime I changed to a Mac, so I have Linux integrated in my SO, but thanks for your answer anyway! It will be a great reference for other memory-bound Windows users who need to develop on Linux systems.
    – DeltaIV
    Commented Jun 5, 2018 at 7:54
  • As of 2023, the bit about WSL2 memory use seems to be incorrect. It may consume up to that amount, but can certainly use less. I have some background processes running in a WSL2 distro, and the vmmemWSL process has a commit size of some ~470MB.
    – Tomeamis
    Commented May 22, 2023 at 15:56
5

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"

0
3

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .