So, I have been using WSL2 on Windows 10 for a while; and I have made a few complaints. The latest one is.
Can't get fcitx to work in WSL2. Also, Win10 multilingual input method sucks, nor does it work with WSL
Pacharapol Withayasakpunt ・ Nov 14 '20
Another major complaint is
WSL 2 consumes massive amounts of RAM and doesn't return it #4166
-
Your Windows build number: 18917
-
What's wrong / what should be happening instead: WSL 2 starts using huge amounts of RAM after a while, just using it like normal. At the moment I'm using phpstorm, and did a dump/load of a database.
Vmmem
is using 7 GB of my 16 GB of RAM and not returning any, even though Ubuntu is actually using much less. I have seen it grow until nearly 100% of my system memory is in use, and it will not release it until I shut down the WSL 2 VM.
This may or may not be related to #4159
corey@Corey-Laptop:/mnt/c/WINDOWS/system32$ vmstat -s
15235516 K total memory
920348 K used memory
1886048 K active memory
6434312 K inactive memory
6606548 K free memory
76280 K buffer memory
7632340 K swap cache
0 K total swap
0 K used swap
0 K free swap
163729 non-nice user cpu ticks
298 nice user cpu ticks
13177 system cpu ticks
68988300 idle cpu ticks
8962 IO-wait cpu ticks
0 IRQ cpu ticks
10022 softirq cpu ticks
0 stolen cpu ticks
1481417 pages paged in
6792976 pages paged out
0 pages swapped in
0 pages swapped out
1079177 interrupts
5131981 CPU context switches
1560599814 boot time
8772 forks
Luckily, I upgraded my laptop from 8GB to 16GB in advance. It uses 8GB RAM at baseline. However, there is no real performance delay.
Compared to my real Linux-first laptop (Ubuntu GNOME 3), which uses less than 1GB RAM (total 8GB RAM - yes, that triple-booted 8-year-old MacBook Pro).
So, I decided to visit my old friend, VirtualBox.
VirtualBox advantages (and cons)
- Graphics and input method engines are all decent and reliable. (Forgot to say that sound doesn't work in WSL2's X410, but does work in VirtualBox.)
- True sandboxing. Better security.
- Of course, a big pro/con of WSL2, is that you can access filesystem, bidirectionally to-and-from Windows. (to-WSL: SSH; from-WSL: network drive)
WSL2 does have some unique cons.
- Web development in WSL2, when opening a server port - the port increases by one in Windows, e.g. 8080 => 8081. None of these shit in VirtualBox.
-
systemd
, and perhaps many other default daemons, does not run at all in WSL2. You cannot always expect things to work the same way as plain old Linux.- This also includes, how to install Docker in WSL2.
- GUI, even with the best xrdp or X410 (or VcXsrv), throws error often. Input method engines do not work.
Of course, VirtualBox comes with the same old cons.
- Harder to set up to be performant. Have to manually allocate not only RAM and hard disk space; but also CPU's and even BIOS settings sometimes.
- Everything is automated and defaulted in WSL2. You don't have to set up anything to be performant. (You might want to limit RAM usage, though.)
- I still cannot figure a way to access WSL2 from VirtualBox. Network drives cannot be accessed from VirtualBox shared folders.
Conclusions
Why not install both?
I am starting to think that, if your PC is powerful enough, use VirtualBox first. But do install WSL2, for the sake of Docker.
Also, consider working at the level of Natively Windows.
Top comments (5)
If automation and ease of setting up is a concern, you can also look at Multipass (multipass.run/).
It shows creating VMs easily using pre installed images, and it supports cloud-init for configuring if desired.
Thanks for your suggestion, and just tested.
mini.iso
, if I really needed to. Also, VirtualBox's GUI makes to easier to manage.If I used Windows 10 Ultimate Edition or something, I might change my mind. But, it doesn't make sense for me to purge genuine Windows 10 that came with the laptop, just to install a more complete version of Windows.
Never had this issue with ports
It's an issue that is obvious to me. It usually hurts nothing, except for gin-swagger.
WSL is still in the prototype phase. It's fun for a while until you get hit with the obnoxious memory drain. +1 for VBox. Not a pleasant experience setting up dev environment w\ WSL.