Linux >= 3.14 provides a "MemAvailable" field in /proc/meminfo which gives the
estimated amount of memory available for applications. Use this to compute glibtop_mem::user. https://bugzilla.gnome.org/show_bug.cgi?id=727543. https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/fs/proc/meminfo.c?id=34e431b0ae398fc54ea69ff85ec700722c9da773
This commit is contained in:
@@ -59,6 +59,12 @@ glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
|
||||
buf->buffer = get_scaled(buffer, "Buffers:");
|
||||
buf->cached = get_scaled(buffer, "Cached:");
|
||||
|
||||
buf->user = buf->total - buf->free - buf->cached - buf->buffer;
|
||||
if (server->os_version_code >= LINUX_VERSION_CODE(3, 14, 0)) {
|
||||
buf->user = buf->total - get_scaled(buffer, "MemAvailable:");
|
||||
}
|
||||
else {
|
||||
buf->user = buf->total - buf->free - buf->cached - buf->buffer;
|
||||
}
|
||||
|
||||
buf->flags = _glibtop_sysdeps_mem;
|
||||
}
|
||||
|
Reference in New Issue
Block a user