elvetemedve / gnome-shell-extension-system-monitor

Gnome Shell extension for displaying resource usage
GNU General Public License v3.0
87 stars 15 forks source link

Use MemAvailable for memory #78

Closed ai closed 3 years ago

ai commented 3 years ago

Closes https://github.com/elvetemedve/gnome-shell-extension-system-monitor/issues/77

I changed used memory calculation more pessimistic by using MemAvailable. Why I think it is better.

Reason 1: MemAvailable is “an estimate of how much memory is available for starting new applications, without swapping”. I think it is better metric.

Reason 2: MemAvailable was added to /proc/meminfo because using MemFree and Cached is not accurate. Quote from the commit to Linux kernel:

Many load balancing and workload placing programs check /proc/meminfo to estimate how much free memory is available. They generally do this by adding up "free" and "cached", which was fine ten years ago, but is pretty much guaranteed to be wrong today.

It is wrong because Cached includes memory that is not freeable as page cache, for example shared memory segments, tmpfs, and ramfs, and it does not include reclaimable slab memory, which can take up a large fraction of system memory on mostly idle systems with lots of files.

Reason 3: I tested this patch and now value is exactly what GNOME System Monitor is showing.

elvetemedve commented 3 years ago

Hi @ai,

Fair enough. I wasn't aware of reason #2.

Thanks for doing the research and for submitting a patch as well. :)