htop-dev / htop

htop - an interactive process viewer
https://htop.dev/
GNU General Public License v2.0
6.32k stars 428 forks source link

Used memory calculation #1307

Open ferre111 opened 12 months ago

ferre111 commented 12 months ago

Due to this issue, the MemAvailable metric was used to calculate the used memory on Linux platforms. However, this decision was later reversed after a discussion in this issue. If I understand correctly, the primary argument for this reversal was to align the calculation of used memory with that of the procps tools. But now these tools use the method mentioned in the first issue. So I would like to ask if there is any more reason why MemAvailable is not use to calculate used memory?

planet36 commented 5 months ago

top, free, and btop use the "MemTotal - MemAvailable" approach, at least on Linux. htop is an outlier with this.

https://gitlab.com/procps-ng/procps/-/blob/master/library/meminfo.c?ref_type=heads#L724 https://gitlab.com/procps-ng/procps/-/blob/master/man/free.1?ref_type=heads#L32 https://gitlab.com/procps-ng/procps/-/blob/master/man/top.1?ref_type=heads#L584 https://github.com/aristocratos/btop/blob/d1680735d9329884c2d46f545a36df32ca5e40cf/src/linux/btop_collect.cpp#L1721