diff --git a/doc/variables.xml b/doc/variables.xml index ab685232..94ce7db9 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -2311,6 +2311,15 @@ Amount of free memory. + + + + + + + Amount of memory used, calculated the same way as in the `free` program. + + diff --git a/src/common.cc b/src/common.cc index 16a42c6c..fcf1c0f8 100644 --- a/src/common.cc +++ b/src/common.cc @@ -395,6 +395,7 @@ double cpu_barval(struct text_object *obj) { PRINT_HR_GENERATOR(mem) PRINT_HR_GENERATOR(memwithbuffers) PRINT_HR_GENERATOR(memeasyfree) +PRINT_HR_GENERATOR(legacymem) PRINT_HR_GENERATOR(memfree) PRINT_HR_GENERATOR(memmax) PRINT_HR_GENERATOR(memdirty) diff --git a/src/common.h b/src/common.h index 26af827d..e39af040 100644 --- a/src/common.h +++ b/src/common.h @@ -105,6 +105,7 @@ double cpu_barval(struct text_object *); void print_mem(struct text_object *, char *, unsigned int); void print_memwithbuffers(struct text_object *, char *, unsigned int); void print_memeasyfree(struct text_object *, char *, unsigned int); +void print_legacymem(struct text_object *, char *, unsigned int); void print_memfree(struct text_object *, char *, unsigned int); void print_memmax(struct text_object *, char *, unsigned int); void print_memdirty(struct text_object *, char *, unsigned int); diff --git a/src/conky.h b/src/conky.h index 52894dba..b91f0f49 100644 --- a/src/conky.h +++ b/src/conky.h @@ -166,7 +166,7 @@ struct information { /* memory information in kilobytes */ unsigned long long mem, memwithbuffers, memeasyfree, memfree, memmax, - memdirty; + memdirty, legacymem; unsigned long long swap, swapfree, swapmax; unsigned long long bufmem, buffers, cached; diff --git a/src/core.cc b/src/core.cc index c7ac8c46..ae044d0a 100644 --- a/src/core.cc +++ b/src/core.cc @@ -1169,6 +1169,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, END OBJ(mem, &update_meminfo) obj->data.s = STRNDUP_ARG; obj->callbacks.print = &print_mem; obj->callbacks.free = &gen_free_opaque; + END OBJ(legacymem, &update_meminfo) obj->data.s = STRNDUP_ARG; + obj->callbacks.print = &print_legacymem; + obj->callbacks.free = &gen_free_opaque; END OBJ(memwithbuffers, &update_meminfo) obj->data.s = STRNDUP_ARG; obj->callbacks.print = &print_memwithbuffers; obj->callbacks.free = &gen_free_opaque; diff --git a/src/dragonfly.cc b/src/dragonfly.cc index d02971d6..9652a0f0 100644 --- a/src/dragonfly.cc +++ b/src/dragonfly.cc @@ -153,6 +153,7 @@ int update_meminfo(void) { info.memmax = total_pages * (pagesize >> 10); info.mem = (total_pages - free_pages - inactive_pages) * (pagesize >> 10); info.memeasyfree = info.memfree = info.memmax - info.mem; + info.legacymem = info.mem; if ((swapmode(&swap_avail, &swap_free)) >= 0) { info.swapmax = swap_avail; diff --git a/src/freebsd.cc b/src/freebsd.cc index 815391ea..a783697b 100644 --- a/src/freebsd.cc +++ b/src/freebsd.cc @@ -170,6 +170,7 @@ int update_meminfo(void) { info.mem = (total_pages - free_pages - inactive_pages) * (pagesize >> 10); info.memwithbuffers = info.mem; info.memeasyfree = info.memfree = info.memmax - info.mem; + info.legacymem = info.mem; if ((swapmode(&swap_avail, &swap_free)) >= 0) { info.swapmax = swap_avail; diff --git a/src/haiku.cc b/src/haiku.cc index 815dfb42..2ec726f7 100644 --- a/src/haiku.cc +++ b/src/haiku.cc @@ -62,6 +62,7 @@ int update_meminfo() { // TODO: we have some more info... info.memwithbuffers = info.mem; info.memeasyfree = info.memfree = info.memmax - info.mem; + info.legacymem = info.mem; info.swapmax = si.max_swap_pages * (B_PAGE_SIZE >> 10); info.swapfree = si.free_swap_pages * (B_PAGE_SIZE >> 10); diff --git a/src/linux.cc b/src/linux.cc index 7df30a1b..4df9f9fe 100644 --- a/src/linux.cc +++ b/src/linux.cc @@ -191,7 +191,7 @@ int update_meminfo(void) { info.memmax = info.memdirty = info.swap = info.swapfree = info.swapmax = info.memwithbuffers = info.buffers = info.cached = info.memfree = - info.memeasyfree = 0; + info.memeasyfree = info.legacymem = 0; if (!(meminfo_fp = open_file("/proc/meminfo", &reported))) { return 0; } @@ -258,6 +258,8 @@ int update_meminfo(void) { info.mem = curmem; info.bufmem = curbufmem; info.memeasyfree = cureasyfree; + info.legacymem = + info.memmax - (info.memfree + info.buffers + info.cached + sreclaimable); fclose(meminfo_fp); return 0; diff --git a/src/netbsd.cc b/src/netbsd.cc index 28028224..54445a87 100644 --- a/src/netbsd.cc +++ b/src/netbsd.cc @@ -127,6 +127,7 @@ void update_meminfo() { info.mem = ((total_pages - free_pages - inactive_pages) * pagesize) >> 10; info.memwithbuffers = info.mem; info.memeasyfree = info.memfree = info.memmax - info.mem; + info.legacymem = info.mem; if (swapmode(&swap_avail, &swap_free) >= 0) { info.swapmax = swap_avail; diff --git a/src/openbsd.cc b/src/openbsd.cc index 9554ee38..10d1f9fd 100644 --- a/src/openbsd.cc +++ b/src/openbsd.cc @@ -174,6 +174,7 @@ void update_meminfo() { info.memmax = pagetok(vmtotal.t_rm) + pagetok(vmtotal.t_free); info.mem = info.memwithbuffers = pagetok(vmtotal.t_rm); info.memeasyfree = info.memfree = info.memmax - info.mem; + info.legacymem = info.mem; if ((swapmode(&swap_used, &swap_avail)) >= 0) { info.swapmax = swap_avail;