this post was submitted on 26 Nov 2024
570 points (97.7% liked)
196
16557 readers
2229 users here now
Be sure to follow the rule before you head out.
Rule: You must post before you leave.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Linux and macOS do the same, although I wouldn't call it lying per se :)
There is certainly a lack of understanding of the difference between free and available RAM. TLDR: yes, free RAM is indeed wasted RAM.
If you actually have a lot of free RAM, it's probably because you either booted or freed a lot of RAM very recently. After using your computer for a while, most of your available RAM should not be free but rather being used for page cache and other caches.
After a program has just read and/or written more data from disk than will fit in available RAM, the kernel's page cache (which is typically the bulk of that not-free-but-available memory) should be mostly populated by the most recent of those operations. This means that if that program (or any other program) reads those files again, before they are evicted from cache by other things, they will not need to wait for the disk and will get them back much faster.
However, managing all of this is the kernel's job, and the not-free-but-available RAM being used for page cache is not (in any OS, as far as I know, though I mostly know Linux) attributed to the program(s) responsible for putting things there.
So, when people are complaining about an application using 40% of their RAM it is not necessarily due to them misunderstanding free-vs-available RAM. The used number for an application does not include the portion of the system's not-free-but-available RAM which the application is also responsible for occupying.
(If you want to know which programs and/or which files are responsible for occupying your page cache... on Linux at least, it is not really possible without instrumenting your kernel. The kernel is just tracking blocks. There several tools which will let you see which blocks of a given file are cached, but there isn't a reverse mapping from blocks to files.)