Comments (3)
One case where disabling the disk cache would be very useful is WSL2. My Windows memory currently is sitting at 97% w/ WSL2 using 17,493 MB, out of ~32GB.
I'm also annoyed that linuxatemyram.com says there are no cases and avoids answering the question. I don't have a problem with "most people shouldn't try to fiddle with this", but in this case AFAIK disabling it would solve my issue. So the site is wrong.
If anyone comes here looking for a way to clear some RAM quickly, a workaround is: echo 1 | sudo tee /proc/sys/vm/drop_caches
. Source and more info
For the curious I posted my usage numbers to: microsoft/WSL#4166
from linuxatemyram.com.
I've created a PR with said workaround: #23
from linuxatemyram.com.
It's a quite old comment but IMO there is an important point that should be noted. So let's start:
I'm also annoyed that linuxatemyram.com says there are no cases and avoids answering the question. I don't have a problem with "most people shouldn't try to fiddle with this", but in this case AFAIK disabling it would solve my issue. So the site is wrong.
The problem with WSL2
is mentioned in their documentation:
You have strict memory requirements
WSL 2's memory usage grows and shrinks as you use it. When a process frees memory this is automatically returned to Windows.
However, as of right now WSL 2 does not yet release cached pages in memory back to Windows until the WSL instance is shut down.
If you have long running WSL sessions, or access a very large amount of files, this cache can take up memory on Windows.
We are tracking the work to improve this experience on the WSL Github repository issue 4166
Also they (Microsoft staff) mention (in the 4166 issue) a pretty aggressive default setting for WSL2 memory up to 80% of host's RAM. Later it is corrected to 50% or 8GB.
This is my attempt to explain the observed behaviour and the underlying problem:
- There is an important missing detail: https://linuxatemyram.com talks about the case when we are using the
Linux kernel
as a host kernel i.e. it is responsible for managing the interactions of the applications with the available hardware including theRAM
memory. Using theMicrosoft WSL2
is not the same case -WSL2
is using aHyperV
virtual machine (VM) to run theLinux kernel
but the Windows kernel is thehost OS kernel
. - So when a given kernel is operating ashost kernel
it doesn't bother with the possibility that something else may need the memory resources. The kernel assumes that the accessible memory is all for its own use. The situation is very different when there are ahost kernel
and aguest kernel
: 1) There is no way for thehost kernel
to ask theguest kernel
: "Give me back some of the memory I've assigned to you". 2) Also there is no way to take it back without breaking the guest memory because the host doesn't know what is and where it is stored in the guest memory. 3) theguest kernel
is not able to say to the host: "Here is some memory range that I no longer need". Conclusion: once the memory is given to the VM/guest kernel
there is no way for thehost kernel
to reclaimed it. This is one of the reasons of containers popularity. The containers are basically native OS processes (with some fancy additional safety net around them) so the host OS can reallocate the freed memory for some other purpose (give it to other process/container or use it as a file system cache). So it is possible to achieve higher density (more isolated computing systems) per one real host. Also if some guest needs temporary more memory it's very easy to achieve. - The old
WSL1
was using a different approach - provide an emulation layer to translate the Linux kernelsystem calls
to their equivalents in the Windows kernel. - in this scenario there is no dedicated memory for a second (guest) kernel so there isn't a possibility to observe the mentioned behaviour. All the RAM is managed by only one kernel.
More resources about the subject (maybe the other could add more related information about the other hypervisors):
- For example Oracle VirtualBox has the feature of
memory ballooning
- it can move thefree
memory from one VM to another. But again it can't reclaim the memory from a guest and return it to the host kernel to be marked asfree
. The details are here: https://www.virtualbox.org/manual/ch04.html#guestadd-balloon
Conclusion:
adding a clarification about the difference between usage scenario only host kernel
and any other usage scenario
should prevent similar confusions.
from linuxatemyram.com.
Related Issues (20)
- Mention TMPFS As Possible RAM Sink HOT 1
- Different memory info format
- Wrong information about megabytes vs mebibytes HOT 1
- Add section for docker HOT 2
- https! HOT 13
- Add disk and memory specifications HOT 1
- Translations? HOT 2
- Point to helpfull resources to "When should I start to worry?"
- Small typo in "What's going on?" section
- License
- How does `free` calculates RAM? HOT 1
- Eaten RAM sometimes remains eaten HOT 1
- Web certificate expired today HOT 1
- Expired SSL Certificates as of 2022-09-17
- different memory info format HOT 1
- I'm Low on RAM! (2)
- (On installations from before 2016,)
- Command to see available ram HOT 1
- Document MemAvailable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linuxatemyram.com.