In this example, when I close my terminal Windows running the WSL distro the page cache is freed naturally by the Linux kernel. Once that memory is freed, then it will also be returned to Windows and your WSL2 VM will shrink in size. If you wish to drop the contents manually you can run echo 1 > /proc/sys/vm/drop_caches as the root user to do so. This is a design decision to ensure you experience the performance improvements of the page cache. We do not free the page cache until the Linux kernel frees it. This is because we accessed a lot of different files, and now our page cache is at 1.7GB in size. You can find the source code here: craigloewen-msft/docker-node-mongo (thank you Github user: bradtraversy for creating the original project!)Īfter we build the images and run the containers, our memory usage is sitting at 2 GB in Windows, even though our in-use memory in Linux is just at 50MB. We’ll run a sample container app that starts up some databases and a NodeJS server using docker-compose. Let’s look at a more real-world example to see how this comes into play. The Linux kernel also uses many caches including a page cache, which caches file contents to improve file system performance. User processes are not the only things that use memory in the Linux VM. The other half of the story: cached memory Then we free the in-use memory, and the ‘vmmem’ process which powers your WSL 2 VM shrinks back down in size, meaning that freed memory is now back on your Windows host, and ready to be used in other applications! Once we run the app, memory use in our Linux distro grows and so does our WSL 2 VM’s memory in Windows. In Linux, we used the free -h command to output the amount of used and cached memory. We’re measuring the memory used in Windows by watching the memory use of the ‘Vmmem’ process which is responsible for the virtual machine that powers WSL2. Here’s the source code: #include Ĭhar* buffer = (char*) calloc(3000000000,1) īefore we run the app, we are using a small amount of memory in both Windows and Linux. We’ll run a simple C application which will use a large amount of memory. When a Linux process releases in-use memory, that memory will then be returned to the Windows host.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |