aristocratos / btop

A monitor of resources
Apache License 2.0
18.79k stars 593 forks source link

[BUG] Incorrect memory usage when zram is enabled #812

Open thefossguy opened 4 months ago

thefossguy commented 4 months ago

Describe the bug

The way that used memory size is being calculated presently seems to be indirectly adding the total zram swap size in it too. This results in the incorrect total usage metric for the actual memory usage

To Reproduce

Run btop with zram swap enabled.

Expected behavior

Do not consider the size of zram swap in total memory usage.

Screenshots Monday 01 April 2024 07_41_27 PM IST

Info (please complete the following information):

thefossguy commented 4 months ago

I'm not familiar enough with the codebase, nor do I use C++ enough to send a PR. But here is how the free utility from the procps set of utilities calculates the used memory value: https://gitlab.com/procps-ng/procps/-/blob/9ebc09e15a73cb3996b0fcdb571f134626ec3264/library/include/meminfo.h#L94