chinf / psensor

A graphical sensor monitoring and logging utility
http://wpitchoune.net/psensor/
GNU General Public License v2.0
64 stars 15 forks source link

mem.available may be more useful than mem.free. #21

Open JamesNewton opened 1 year ago

JamesNewton commented 1 year ago

As per https://gitlab.com/jeanfi/psensor/-/issues/10 "On my laptop (Ubuntu 18.04, 8750H, Geforce 1070), pSensor 1.1.5 reports free memory percentage and used GPU memory percentage. This inconsistency is confusing."

The better measure of memory is, I think, mem.available rather than mem.free.

This can be tested by just changing https://github.com/chinf/psensor/blob/master/src/lib/pgtop2.c#L98 from v = ((double)mem.free) * 100.0 / mem.total; to v = ((double)mem.available) * 100.0 / mem.total;

And then if it works as expected, perhaps a second memory sensor can be added.

JamesNewton commented 1 year ago

Never mind, libgtop does not have mem.available. It does, however, have mem.user, which includes total - available. https://github.com/GNOME/libgtop/blob/master/sysdeps/linux/mem.c#L63