matryer / xbar

Put the output from any script or program into your macOS Menu Bar (the BitBar reboot)
https://xbarapp.com
MIT License
17.56k stars 643 forks source link

High Memory usage issue #725

Open DefCon-007 opened 3 years ago

DefCon-007 commented 3 years ago

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

leaanthony commented 3 years ago

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

DefCon-007 commented 3 years ago

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.

pdondl commented 3 years ago

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.

leaanthony commented 3 years ago

Is it sometimes or always? 😄

pdondl commented 3 years ago

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

DamiansDesign commented 3 years ago

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

Etheryte commented 3 years ago

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.

DefCon-007 commented 3 years ago

@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.

leaanthony commented 3 years ago

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

leaanthony commented 3 years ago

This is fixed by #731

matryer commented 3 years ago

@DefCon-007 Any chance you can confirm this?

DefCon-007 commented 3 years ago

@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.

DamiansDesign commented 3 years ago

@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 commented 3 years ago

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

shinepixel commented 3 years ago

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.

Etheryte commented 3 years ago

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.

matryer commented 3 years ago

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

leaanthony commented 3 years ago

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

Etheryte commented 3 years ago

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

shinepixel commented 3 years ago

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

samsamoa commented 2 years ago

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

MrDrache333 commented 2 years ago

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

booi commented 2 years ago

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
leaanthony commented 2 years ago

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

Etheryte commented 2 years ago

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.

stavfx commented 2 years ago

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

booi commented 2 years ago

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

Rusca8 commented 2 years ago

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.