Airblader / i3

A fork of the i3 window manager with gaps and some other features. :warning: i3-gaps has been merged into i3.
BSD 3-Clause "New" or "Revised" License
5.87k stars 318 forks source link

i3bar & conky - hard memory leak and delays #59

Closed mersinvald closed 9 years ago

mersinvald commented 9 years ago

I'm using conky with JSON output as statusline provider for i3bar. The problem (as I see it) is i3bar parsing the whole JSON every second, and, as it's grow, this process takes more and more time and memory. This leads to hard memory leak and really huge slow down after ~20 minutes.

Here are my measurements. i3 resources consumption after:

Launch RAM: <1% (~20MB) CPU:1%

5 minutes RAM: ~3% (~115MB) CPU: ~3.3%

Delays becomes as big so I can feel `em: RAM: ~20% (~800MB) CPU: ~30%

i3bar:

bar {
status_command $HOME/.i3/conky/i3bar-conky.sh 
position top
font pango: Fira Mono, Icons 8
strip_workspace_numbers no

separator_symbol 

height 18

 colors {
     statusline         $white
     background         $background
     separator          $cyan
     #                          BORDER      BACKGROUND  TEXT
     focused_workspace  $background $background $white
     inactive_workspace $background $background $darkcyan
     active_workspace   $background $background $white
     urgent_workspace   $darkcyan   $darkcyan   $background
     binding_mode       $background $background $darkcyan
     }
}

i3bar-conky.sh

#!/bin/sh

# Send the header so that i3bar knows we want to use JSON:
echo '{"version":1}'

# Begin the endless array.
echo '['

# We send an empty first array of blocks to make the loop simpler:
echo '[],'

# Now send blocks with information forever:
exec conky -c $HOME/.i3/conky/conkyrc

conkyrc

out_to_x no
own_window no
out_to_console yes
background no
max_text_width 0

# Update interval in seconds
update_interval 1.0

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
#total_run_times 0

# Shortens units to a single character (kiB->k, GiB->G, etc.). Default is off.
short_units yes

# Add spaces to keep things from moving about?  This only affects certain objects.
# use_spacer should have an argument of left, right, or none
use_spacer left

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

text_buffer_size 1000

# Stuff after 'TEXT' will be formatted on screen
TEXT
# JSON for i3bar
[ \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "test", "separator" : "false"}, \
{ "full_text" : "${exec setxkbmap -v 7 | grep layout | awk '{print $2}'}" , "separator" : "false", "color" :  "\#FFD700" }, \
{ "full_text" : "cpu $cpu%${acpitemp}°C" , "separator" : "false", "color" : "\#ffffff" }, \
{ "full_text" : " ${time %b %d, %a %R}", "separator" : "false"} \
], \

i3 --version

i3 version 4.10.4-705-g2f1c242 (2015-09-24, branch "branch-gaps-next") © 2009 Michael Stapelberg and contributors

conky --version

Conky 1.9.0 compiled Tue Sep 15 19:56:18 MSK 2015 for Linux 4.2.0-gentoo-r1 (x86_64)

Compiled in features:

System config file: /etc/conky/conky.conf
Package library path: /usr/lib64/conky

 X11:
  * Xdamage extension
  * XDBE (double buffer extension)
  * Xft
  * ARGB visual

 Music detection:
  * MPD
  * MOC

 General:
  * portmon
  * wireless
  * support for IBM/Lenovo notebooks
  * config-output
  * ncurses

umane -a

Linux PonyBook 4.2.0-gentoo-r1 #7 SMP PREEMPT Mon Sep 21 16:42:03 MSK 2015 x86_64 Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz GenuineIntel GNU/Linux
mersinvald commented 9 years ago

If needed, I can also make gcore dump file

Airblader commented 9 years ago

The problem (as I see it) is i3bar parsing the whole JSON every second, and, as it's grow, this process takes more and more time and memory.

I'm fairly confident that it doesn't (this would affect almost every user, which it doesn't). What makes you think that?

Anyway, I don't see that this would be related to i3-gaps. Please reproduce this with vanilla i3 and report it at i3/i3. If you cannot reproduce it with vanilla i3, drop a comment here and we will reopen it.

In preparation for the ticket at i3, please provide an i3bar log file (see the debugging docs in the current "next" branch) and also disable i3bar and just run the conky command in a terminal for a while to see if this produces a mem leak.