Used memory for the system is always total minus available.
Heuristics? I would hope that the system knows precisely what is using every single byte of physical and virtual memory. Is this a reporting problem? Why do we have to settle for heuristics and not the exact number?
Of course the system knows what is using every page. The difficulty is really in how to account for pages that are backed by disk.
If you count all of those as free, that's not accurate. If you count all of those as used, that's not accurate either. Additionally, FreeBSD (at least) doesn't have separate queues for disk backed pages, so there's not really a good way to know how much of your active (or inactive) memory is disk backed.
As an additional caveat that measuring active/inactive has costs. In the past, FreeBSD wouldn't really do the work for that until it needed to... I know some stuff changed, but I don't remember where it ended up; it wasn't great when it bulk marked a ton of pages as inactive and then the active ones would fault back in.
Why not? It depends on what you’re measuring. Physical memory? They count as free. Virtual memory? They count as used.
The ambiguities only arise when we stop making that distinction very clear.
This isn’t hard. The OS should just expose a counter for available memory instead of having applications understand every type of memory reservation.
edit:
Linux does this, but it has its own share of issues with memory counters. The “cached” memory includes tmpfs and ramfs for seemingly no reason.
The nice thing about e-textbooks is not needing to carry around a bunch of heavy books. I remember the tomes I had in my college days, such as Stewart's Calculus.
Then some NetBSD dev wrote on their mailing list that this is no longer true. Linux runs on more toasters now. (And also top 500 supercomputers, but toasters are the real metal to the petal test.)
These fights always remind me of:
https://www.jwz.org/doc/worse-is-better.html
It's an interesting piece of history too. I kind of evaluate it a bit differently, e. g. my summary is "momentum beats academic perfection". Which is not completely what it is about, but it is my own imperfect TL;DR summary.
User installs an unfamiliar server OS with an enterprise filesystem and is stunned when it works differently. I fail to see a teachable moment here.
Poor FreeBSD folks though. After so many years trying to present themselves as better alternative, the road just got steeper ...
https://peteris.rocks/blog/htop/
I was looking forward for web protocol, but alas...
But there is an http headers article you might like.
https://peteris.rocks/blog/exotic-http-headers/