brndnmtthws / conky

Light-weight system monitor for X, Wayland (sort of), and other things, too
https://conky.cc
GNU General Public License v3.0
7.28k stars 620 forks source link

Linux: memory report includes cached memory even with 'no_buffers = true' #860

Closed ghost closed 5 years ago

ghost commented 5 years ago

Issue This MAY be a duplicate of #857, but I'm making a separate issue because it might not since this seems configuration-specific.

I noticed that the reporting on memory in Linux was incorrect. Conky is including cached memory in the memory usage numbers (top right "%44 6.99GiB") whereas htop reports the actual number (1.88G). 2019-07-01-005348_486x134_scrot

I did a lot of digging around to figure out what might be the problem, and I think I narrowed it down to commit c352069b "Add support for nested |exec| expressions"

The issue seems to be that with nested exec expressions, and the added support, it causes an odd behavior with run_all_callbacks(). For some reason, update_stuff() in common.cc doesn't appear to adjust info.mem in the if (no_buffers.get(*state)), even with no_buffers = true explicitly set in .conkyrc

HOWEVER this only seems to happen when execp objects are used in .conkyrc: (EDIT: after further testing it turns out I'm bad at this)

When building with a commit before c352069b, this doesn't happen, which leads me to believe this has something to do with how evaluate() is being called, and probably with run_all_callbacks() being called within evaluate(). My guess is that having a double run_all_callbacks() is causing the info.mem* variables to be overwritten by the callbacks after it is adjusted in update_stuff().

Fix Moving the if (no_buffers.get(*state)) block from update_stuff() in common.cc to update_meminfo() in linux.cc as suggested in the comment seems to do the trick.

I'd do the PR myself but I'm not exactly sure how to go about describing how I tested/validated any changes since I don't know if I actually have a grasp on what's going on.

Information Running Arch Linux conky 1.11.4_pre compiled for Linux 5.1.15-arch1-1-ARCH x86_64

conky.config = {
  out_to_x = false,
  out_to_console = true,
  no_buffers = true,
  update_interval = 1.0,
  total_run_times = 0,
}
conky.text = [[${execpi 1 [script]} ... %${memperc} ${mem} ]]
brainpower commented 5 years ago

I observe the same issue on all my PCs since updating from 1.11.3 to 1.11.4 . Also running Arch Linux.

I can also confirm that the referenced commit ba33f9a restores the behavior of 1.11.3. ($mem and $memwithbuffers showing different values again, whereas they've been always the same with 1.11.4, no matter what no_buffers was set to) But can't say if it's the correct way to fix this.

azhi commented 5 years ago

Just got bit by similar issue as well.

In my case ${mem} and ${memeasyfree} in my conky.text show correct values (taking conky.no_buffers = true into account), but evaluating same thing in lua using conky_parse gives incorrect values (as if conky.no_buffers was set to false).

Can confirm that @CtrlSequence fix works for me. Not sure where to leave this comment, similar discussion happens in #857 and #859, but fix in #859 is a bit more complicated - my issue is fixed just by moving mem and memeasyfree calculation to linux.cc.

lasers commented 5 years ago

Closed via https://github.com/brndnmtthws/conky/pull/871.