You are not logged in.

#1 2018-03-02 15:20:01

frabjous
Member
Registered: 2010-07-13
Posts: 367

[SOLVED] Why would the i3bar use over 2GB of memory?

I'm seeing the i3bar utilize far more memory than I ever would have expected.

E.g., today I saw this:

$ ps x | grep [i]3bar
15923 ?        S     21:50 i3bar --bar_id=bar-0 --socket=/run/user/1000/i3/ipc-socket.508
$ pmap 15923 | tail -n 1
 total          2600624K

Well over 2GB of memory in use for the i3 bar?

Here's the bar configuration in my i3 config, in case that's relevant:

bar {
        position top
        tray_output none
        status_command i3blocks
        strip_workspace_numbers yes
        font pango: Overpass 12
}

From what I can tell, this number grows over time. If I restart i3 in place, the number the shrinks significantly (down to around 100MB, though it is still pretty large). The longer I leave i3 running, the more memory it uses. The above numbers come from around a week of the i3bar running.

I do have some interesting i3block commands which launch other processes ocassionally, but this number remains high even while none of them are running.

Is it keeping all the output of the i3blocks commands in memory, even after they've been overwritten? (Though even then it seems like it should take longer to get that high.)

This hasn't actually caused any performance problems, as I have plenty of RAM, but it still confuses me, and makes me worry I have something poorly configured.

Last edited by frabjous (2018-03-05 13:45:46)

Offline

#2 2018-03-02 16:16:45

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,701

Re: [SOLVED] Why would the i3bar use over 2GB of memory?

My uptime is 6 days.  I am logged into my system on two consoles running i3 on each of them.  Therefore I have 2 instances of ibar.   They both take about 96 MB

ewaller@turing ~ 1010 %ps x | grep bar
 1863 pts/6    S+     0:00 grep bar
 7248 ?        S      2:45 i3bar --bar_id=bar-0 --socket=/run/user/1000/i3/ipc-socket.7215
 9551 ?        S      2:35 i3bar --bar_id=bar-0 --socket=/run/user/1000/i3/ipc-socket.4477
ewaller@turing ~ 1011 %pmap 7248 | tail -1
 total            96588K
ewaller@turing ~ 1012 %pmap 9551 | tail -1
 total            96592K
ewaller@turing ~ 1013 %

My config lines

# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
        status_command i3status
	mode dock
	binding_mode_indicator yes
	position bottom
  colors {
        background #002000
        statusline #ffffff
        separator #ffff00

        focused_workspace  #4c7899 #207020 #ffffff
        active_workspace   #333333 #5f676a #ffffff
        inactive_workspace #333333 #222222 #ffffff
        urgent_workspace   #2f343a #900000 #ffffff
        binding_mode       #2f343a #900000 #ffffff
    }
}

Never used i3-blocks myself, but it would appear there is some sort of memory leak going on.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2018-03-04 00:12:47

frabjous
Member
Registered: 2010-07-13
Posts: 367

Re: [SOLVED] Why would the i3bar use over 2GB of memory?

Thanks, ewaller. I'm not sure what to do except remove all my i3blocks components and then put them back one by one, in the attempt to figure out which one is causing the leak. Since it takes a long time for the memory usage to grow, this might take a long time to figure out.  Thanks for your help. I'll report back with my findings, if they seem relevant to others anyway.

Offline

#4 2018-03-04 01:39:56

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: [SOLVED] Why would the i3bar use over 2GB of memory?

That number shown by pmap is I think about the "virtual" memory of the program. That's not the same as actual RAM use. For the physical memory use, you have to look at the "RES" column in top or htop. You can also view it with 'ps' like this:

$ ps -O vsz,rss -C i3bar
  PID    VSZ   RSS S TTY          TIME COMMAND
 1105  97860 11636 S ?        00:00:02 i3bar --bar_id=bar-0 --socket=/run/user/1000/i3/ipc-socket.695

Check that out for you. Things are probably not as bad you think. That "VSZ" column is named "VIRT" in top/htop and seems to be what you see in pmap's total. The "RSS" column is the actual memory use.

There's also an interesting program named "smem" that tries to do something smart about the memory used for shared libraries. The memory used by a shared library is counted in the RSS memory for every program that uses it, but it really is shared. That 'smem' tool I think divides that memory between all programs to get a "PSS" number:

$ smem -k -P ^i3bar
  PID User     Command                         Swap      USS      PSS      RSS 
 1105 secret   i3bar --bar_id=bar-0 --sock        0     1.2M     2.2M    11.6M 

Here you can see that PSS number is a lot lower than the RSS number.

Last edited by Ropid (2018-03-04 01:40:46)

Offline

#5 2018-03-04 15:44:13

frabjous
Member
Registered: 2010-07-13
Posts: 367

Re: [SOLVED] Why would the i3bar use over 2GB of memory?

Thanks a lot, Rapid.

Right now, i3 has been running for about 12 hours, and I'm seeing this:

$ ps -O vsz,rss -C i3bar
  PID    VSZ   RSS S TTY          TIME COMMAND
  488 274884 182584 S ?       00:00:52 i3bar --bar_id=bar-0 --socket=/run/user/1000/i3/ipc-socket.457
$ smem -k -P ^i3bar
  PID User     Command                         Swap      USS      PSS      RSS 
  488 secret   i3bar --bar_id=bar-0 --sock        0   169.9M   170.8M   178.1M 

That's a little better, but still not what I hoped to see, and the PSS number is not significantly lower than the RSS number. But the real question is what happens as time goes on. I'll have to wait and see.

Offline

#6 2018-03-05 13:45:01

frabjous
Member
Registered: 2010-07-13
Posts: 367

Re: [SOLVED] Why would the i3bar use over 2GB of memory?

OK, I seem to have figured out the problem. I was using some colored emojis in my workspace names and i3blocks output, using Noto Color Emoji as a fallback font, using the instrucitons here. These seem to be cause of the huge memory usage.

When I took them out, and stuck to plain ASCII output, and restarted things, I've been below 10 mb or memory usage for i3bar, even running overnight; about 16 hours total now.

I'll have to go without the emojis for now; it's a shame though as they added a splash of color to an otherwise mundane bar.

Offline

#7 2018-03-05 14:23:15

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,420
Website

Re: [SOLVED] Why would the i3bar use over 2GB of memory?

Consider filing a bug with i3blocks now that you've identified the cause of the memory leak. wink


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#8 2018-03-05 15:24:24

progandy
Member
Registered: 2012-05-17
Posts: 5,321

Re: [SOLVED] Why would the i3bar use over 2GB of memory?

That should be a bug in pango, it doesn't seem to free colored glyphs correctly.

Edit: Simple test code: http://ix.io/SUq

gcc -o emojitest test.c -lm $(pkg-config --libs --cflags pangocairo)

memusage -T -p /tmp/emoji-text-mem ./emojitest /tmp/emoji-text.png 9000 ':D'

memusage -T -p /tmp/emoji-color-mem ./emojitest /tmp/emoji-color.png 9000 '?'

Last edited by progandy (2018-03-05 15:58:35)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#9 2018-03-23 00:27:13

progandy
Member
Registered: 2012-05-17
Posts: 5,321

Re: [SOLVED] Why would the i3bar use over 2GB of memory?

https://bugzilla.gnome.org/show_bug.cgi?id=794209

It seems this is/was a bug in cairo. My test doesn't leak anymore with cairo 1.15.10+54+g1ed124ace-1 which is currently in [testing].


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#10 2018-03-23 15:20:58

frabjous
Member
Registered: 2010-07-13
Posts: 367

Re: [SOLVED] Why would the i3bar use over 2GB of memory?

Thanks a lot for following up on this, progandy!

Offline

Board footer

Powered by FluxBB