htop
htop copied to clipboard
Wrong memory usage on BSD and derivatives.
So here's an example: https://s.verknowsys.com/1cfc4d97db733029aa928d94c78d0207.png
influxd is using over 48G of RSS, but total memory usage of the system in htop is 28G.
Shouldn't htop count Total Memory as Active + Inactive + Laundry + Wired?
What does vmstat report?
Which *BSD port exactly do you use? Or have you confirmed this issue with multiple platforms? If so, which?
All BSDs (and MacOS too) will have a very similar (or the same) memory model, but I use FreeBSD 13.0 arm64/amd64 and MacOS 12.3 arm64.
The vmstat on that FreeBSD 13.0 host shows:
procs memory page disks faults cpu
r b w avm fre flt re pi po fr sr nv0 nv1 in sy cs us sy id
1 0 1 27G 4.0G 2.2K 171 78 1 4.4K 14K 0 3212 5593 33K 30K 23 10 67
The top utility shows this:
Mem: 18G Active, 28G Inact, 2028K Laundry, 11G Wired, 4102M Free
(where htop shows "23.8G/63.7G" in Mem line)
The Reddit post mentioned at https://github.com/htop-dev/htop/issues/1039#issuecomment-1157206516 includes this comment:
… think that it subtracts the arc cache from the actual memory usage when it updates, then it's wraps around backward all the way to the top. …
If the 16.0Z symptom in #1039 is not observable in this issue #955, it may be because I'm using L2ARC.
If we're to compare with top(1) https://www.freebsd.org/cgi/man.cgi?query=top&sektion=1&manpath=FreeBSD, then a most significant difference might be the perception of what's free.

- 372 M free according to top
- much more free according to htop (altered according to https://github.com/htop-dev/htop/issues/1039#issuecomment-1157564395)
In my MacOS Monterey 12.4 with apple M1 pro, compare top and htop also have this problem.
On FreeBSD (OPNsense) I'm also seeing wrong memory counting.
Repro:
- Mount a tmpfs
- Fill tmpfs with data
- Observe top reducing free memory
- Observe htop still reporting lots of free memory
Thanks!