xbar icon indicating copy to clipboard operation
xbar copied to clipboard

High Memory usage issue

Open DefCon-007 opened this issue 3 years ago • 28 comments

I only have 4 plugins installed and then also the memory usage is ~5 GB, would like to know how to dive deep in figuring out the issue here and resolving it. Screenshot 2021-05-26 at 12 52 29 AM

Also, the CPU usage is pretty high too. Screenshot 2021-05-26 at 12 55 28 AM

DefCon-007 avatar May 25 '21 19:05 DefCon-007

Is this true regardless of which plugins you use or can it be isolated to a particular plugin?

leaanthony avatar May 27 '21 20:05 leaanthony

Have not tried with correlating with a plugin but I went through the code of all four plugins and didn't see anything there. Is there any direct way to isolate memory profiling of each plugin? If not, would be good feature ensuring long term sustainability and easier maintenance of xbar.

DefCon-007 avatar May 30 '21 10:05 DefCon-007

i'm running only one plugin that i wrote myself (adapted from the ssh tunnel plugin). at first, xbar uses ~50Mb of ram, but it seems to sometimes balloon to 1Gb.

pdondl avatar May 31 '21 08:05 pdondl

Is it sometimes or always? 😄

leaanthony avatar May 31 '21 11:05 leaanthony

Memory footprint seems to be continuously growing. 4 hours ago it was ~50Mb, now it's ~90Mb (all according to Activity Monitor).

pdondl avatar May 31 '21 12:05 pdondl

I'm also seeing high memory usage. With one plugin installed, after a few days xbar is over 1.2GB of memory usage.

DamiansDesign avatar Jun 01 '21 00:06 DamiansDesign

This doesn't seem to be plugin-specific. I didn't find this ticket before so I ended up opening a new one with some more technical details in https://github.com/matryer/xbar/issues/731, the underlying problem should be the same.

Etheryte avatar Jun 17 '21 13:06 Etheryte

@Etheryte Thank you for such detailed explanation, for the time being I had to completely stop using the app as after sometime it was making my complete system unusable. Looking for more inputs so that we can fix this as soon as possible.

DefCon-007 avatar Jun 17 '21 19:06 DefCon-007

I'll be addressing this over the next week. Thanks for your patience 👍

leaanthony avatar Jun 18 '21 00:06 leaanthony

This is fixed by #731

leaanthony avatar Jun 29 '21 13:06 leaanthony

@DefCon-007 Any chance you can confirm this?

matryer avatar Jul 14 '21 09:07 matryer

@matryer I didn't get a chance to test again. I am on vacation and will be able to take a look after a week. I will let you know after that.

DefCon-007 avatar Jul 14 '21 15:07 DefCon-007

@matryer I can confirm since v2.1.0-beta I'm not seeing xbar memory usage balloon like previous versions.

Thank you for fixing this!

DamiansDesign avatar Jul 14 '21 23:07 DamiansDesign

After 13 days of xbar (v2.1.4-beta) running with one plugin, memory usage is up to 918 MB.

DamiansDesign avatar Jul 28 '21 02:07 DamiansDesign

This issue seems to be connected to plugins using custom icons. I tested it, using only one plugin. This plugin runs every 30 minutes and does nothing else but display a custom icon (PDF converted to Base64). Memory usage of xbar increases by around 100 MB per day. Using v2.1.6-beta.

shinepixel avatar Sep 18 '21 07:09 shinepixel

The issue is present in text-only plugins as well, albeit perhaps at a smaller scale. I don't use custom icons and also experience increased memory use over time. Currently I've simply set a cronjob to periodically kill the process as a workaround, but obviously that's not very neat.

Etheryte avatar Sep 18 '21 10:09 Etheryte

@leaanthony and I will dig into this in our next session, thanks for all the leads everyone.

matryer avatar Sep 18 '21 11:09 matryer

If you can link to a gist with a plugin that reproduces this, it'd help us debug. Last time i did this, i got zero memory leaks so this will be fun

leaanthony avatar Sep 18 '21 11:09 leaanthony

For me, the issue is reproducible with the following plugin foo.1s.sh (all other plugins removed):

#!/usr/bin/env bash

echo "foo"

Memory use grows roughly 15MB per 10 minutes.

macOS version: 10.15.7 xbar version: v2.1.6-beta

Etheryte avatar Sep 18 '21 14:09 Etheryte

Here you find a plugin with custom icons: https://gist.github.com/shinepixel/a282ba7245f7afa247de09765e0ab268

I did stress test with running it every 5 seconds. While this does increase memory usage, it does not make a huge difference compared to running it every 30 minutes. Somehow it is not (that) important how often the plugin is run.

When using a text-only plugin (with emojis) memory usage does increase over time, but not in a significant/bothering amount.

xbar v2.1.6-beta on macOS 11.4

shinepixel avatar Sep 19 '21 09:09 shinepixel

for what it's worth, I'm seeing an issue where memory usage sometimes spikes suddenly to ~70-80GB. not sure if related — I'll post more if I can reproduce it more cleanly. image

samsamoa avatar Nov 22 '21 16:11 samsamoa

Same here with Latest Version of macOS. xBar over 34GB Memory.

MrDrache333 avatar Mar 07 '22 19:03 MrDrache333

Same here on MacOS Big Sur 11.6.2 running xbar 2.1.7-beta and I only run 1 plugin, the UTC plugin.

image

It seems like there's a memory leak somewhere

image

booi avatar Apr 11 '22 16:04 booi

Hey all 👋 We aim to look at this as a priority over the next week.

leaanthony avatar Apr 11 '22 22:04 leaanthony

I'd like to note one thing on the side here, which is don't sweat it. You've built this application for free and are giving it away in kind. Naturally people will point it out if something's broken, but you shouldn't sweat it or be stressed about it. This is figuratively free beer, and naturally everyone will be happy if there's more free beer, but if you don't have any more free beer at one point, that's fine too — we're still grateful for all the free beer there was.

Etheryte avatar Apr 11 '22 22:04 Etheryte

Don't listen to @Etheryte. We demand more free beer! (jk, restarting xbar once a week won't kill us 😛 )

stavfx avatar Apr 12 '22 21:04 stavfx

Can someone let me know where to send the beer tho?

booi avatar Apr 12 '22 21:04 booi

Hi. I was having this issue too on MacOS 10.14.6 Mojave (with a custom plugin I made using Python3). It uses custom icons too, as people were commenting (it's an alternate clock that displays emojis as an alternative to the japanese weekday). For now I solve it by forcing quit on it every now and then. Not a big problem, but it's indeed weird.

Rusca8 avatar Apr 20 '22 17:04 Rusca8