If you're curious why that is by the way, it's because that's actually how these are implemented (tmpfs/ramfs is just a mount to a filesystem where the files never get marked clean[1])
[1]: https://www.kernel.org/doc/Documentation/filesystems/ramfs-r...
AFAIK the only way for you to figure out how much of your disks is actually cached involves enumerating all tmpfs and ramfs mounts, summing their sizes, and subtracting the sum from the cache size reported by the kernel.
> The OS should just expose a counter for available memory instead of having applications understand every type of memory reservation.
Explicitly set per-application upper bounds à la GOMEMLIMIT and Java's -Xmx, together with cgroup's enforcement, seem to be much more useful in practice.
Or there was a proposal for some sort of SIGLOWEM signal that would be sent to all processes in the system (with default disposition of "do nothing") that'd allow applications to release some of its non-vital memory holdings: also a much more timelier notification.
Do agree it's not the best UX and utilities should probably do a better job at showing that
[1]: https://man7.org/linux/man-pages/man5/proc_meminfo.5.html
It won't count executable pages and memory-mapped file use as "used" memory, so your system might display gigabytes "free" when it's starving, executables getting paused when code pages are paged-in from disk.
It's just less useful than what's displayed now. "Everyone is doing it wrong" is usually a signal that you're missing something.
You can't determine how much of the memory can actually be reclaimed under memory pressure until you try to reclaim it.
Yes, and I’m arguing that we should be able to, by having the kernel keep track.