sm00th / bitlbee-discord

Bitlbee plugin for Discord (http://discordapp.com)
GNU General Public License v2.0
291 stars 27 forks source link

Memory leak #147

Closed rcx closed 6 years ago

rcx commented 6 years ago

Thanks for writing this plugin. It's very useful , but lately I've been experiencing memory leaks in bitlbee only when my Discord accounts are online.

Maybe you could diagnose this sometime? Apologies for the vague bug report.

sm00th commented 6 years ago

Hm, yes, it is rather vague. How did you find it? How do you know that's a leak? If possible can you estimate the rates at which it is leaking? If you've been using the plugin for a while - did this start with some recent update?

I did check on an instance I had running for a couple of months and the memory consumption is roughly the same as on a freshly spawned instance.

rcx commented 6 years ago

It's a very slow leak, about ~300MB / 24 hours. I initially discovered it on htop when the memory usage was very high. It's been happening since I started using the plugin several months ago, but I worked around it by just restarting bitlbee every 24 hours or so.

If this leak isn't reproducible then please feel free to close the issue.

dgw commented 6 years ago

Hmm… My BitlBee instance (running since April 13) is pretty lean still, sitting at 93048 VSZ / 33604 RSS. That's the PID that's running my user; the master process's resource usage is much lower still.

One variable to consider here is whether @ecx86 is using BitlBee in Daemon or ForkDaemon mode. I use ForkDaemon mode, and am observing negligible memory usage by BitlBee. (It's certainly much lower than the NodeJS IRC client I use to actually connect to BitlBee.) The run mode could affect things, as could the number of Discord servers, number of channels, and number of users the Discord plugin is tracking. Auto-join being on or off would be relevant info, and whether the never_offline option is in use (my instance has it turned on).

Just trying to think of things that could result in memory being repeatedly allocated and (not) freed. I haven't dug through the code for either this plugin or BitlBee itself, in fairness. This is pure speculation.

sm00th commented 6 years ago

Oh, 300Mb in 24 hours is a lot. I don't think we should close it even though I can't reproduce it. Someone else can stop by with the same problem and more details. I might not be seeing this because I'm not in any high-traffic-lots-of-people "servers" on discord.

I'd recommend updating both bitlbee and bitlbee-discord to latest available versions. Also if you feel adventurous you can try running bitlbee under valgrind to try to find any leaks. To do that you should shutdown your bitlbee, disconnect all clients and then run it like so:

valgrind --leak-check=full --suppressions=glib.supp --log-file=valgrind.log bitlbee -nvD (suppression file can be found in glib's repo: https://github.com/GNOME/glib/blob/master/glib.supp)

Keep it running like that till it starts eating memory and then you can check valgrind.log for any leak-reports. That log won't contain any sensitive information so it is safe to upload.

rcx commented 6 years ago

Ok, some details: I idle in several large Discord chat channels, and I have a control channel populated with my Discord contacts.

Since I've opened this issue, I've moved from Debian to Ubuntu, recompiled bitlbee and bitlbee-discord, and switched to ForkDaemon mode. The memory usage seems better, so I will close the issue in a few days if the leak seems gone.