From f827842abfe41c6c8cb4b5b4dbdee10336546cf8 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Fri, 11 Nov 2005 05:28:20 +0000 Subject: [PATCH] fixed small prob with memory stuff being wrong git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@391 7f574dfc-610e-0410-a909-a81674777703 --- src/common.c | 5 +++-- src/linux.c | 6 +++++- src/top.c | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/common.c b/src/common.c index 1012b475..a7d91144 100644 --- a/src/common.c +++ b/src/common.c @@ -230,11 +230,12 @@ void update_stuff() update_load_average(); - if ((NEED(INFO_MEM) || NEED(INFO_BUFFERS)) && + if ((NEED(INFO_MEM) || NEED(INFO_BUFFERS) || NEED(INFO_TOP)) && current_update_time - last_meminfo_update > 6.9) { update_meminfo(); - if (no_buffers) + if (no_buffers) { info.mem -= info.bufmem; + } last_meminfo_update = current_update_time; } diff --git a/src/linux.c b/src/linux.c index fb2fc70f..fb57fe7e 100644 --- a/src/linux.c +++ b/src/linux.c @@ -122,12 +122,16 @@ void update_meminfo() sscanf(buf, "%*s %lu", &info.cached); } } - + info.mem = info.memmax - info.mem; info.swap = info.swapmax - info.swap; info.bufmem = info.cached + info.buffers; + /*if (no_buffers) { + info.mem -= info.bufmem; + }*/ + info.mask |= (1 << INFO_MEM) | (1 << INFO_BUFFERS); } diff --git a/src/top.c b/src/top.c index 78996713..47db8b45 100644 --- a/src/top.c +++ b/src/top.c @@ -495,6 +495,9 @@ void sp_acopy(struct sorted_process *sp_head, struct process ** ar, int max_size } } +// stole from common.c +#define NEED(a) ((need_mask & (1 << a)) && ((info.mask & (1 << a)) == 0)) + /* ****************************************************************** */ /* Get a sorted list of the top cpu hogs and top mem hogs. */ /* Results are stored in the cpu,mem arrays in decreasing order[0-9]. */ @@ -513,7 +516,7 @@ inline void process_find_top(struct process **cpu, struct process **mem) update_process_table(); /* update the table with process list */ calc_cpu_each(total); /* and then the percentage for each task */ process_cleanup(); /* cleanup list from exited processes */ - update_meminfo(); + cur_proc = first_process; while (cur_proc !=NULL) {