chatterino2 icon indicating copy to clipboard operation
chatterino2 copied to clipboard

Chatterino has a memory usage problem

Open TETYYS opened this issue 4 years ago • 18 comments

Describe your issue Chatterino either leaks or retains too much memory for something. Memory usage seems to increase over time, but not linearly - for example my current chatterino instance uses 1.67GB private bytes for 3d3h runtime.

Applications like MTuner might help to find the cause.

Screenshots ProcessHacker_hkQ4qxOm6F

OS and Chatterino Version Win10 20H2 19042.1052 Chatterino Nightly 2.3.2 (commit f9ddd5303, )

TETYYS avatar Jul 23 '21 09:07 TETYYS

Maybe the debug popup (F10) can help. cf. my one, after a day or so of running 2021-07-23_13-52

Mm2PL avatar Jul 23 '21 11:07 Mm2PL

lots of message layout elements

chatterino_nJs5uu4Kxd

TETYYS avatar Jul 23 '21 11:07 TETYYS

I'm sure messages are leaked somewhere (I had no channels but there were messages) but I can't replicate it consistently.

This might be the bug? When messages scroll off the split, they aren't properly deleted. Their Layout Elements stay leaking memory. However they are deleted as soon as the split/channel is.

Mm2PL avatar Jul 23 '21 12:07 Mm2PL

Yeah, seems like it. I deleted and recreated a couple of splits and managed to get it down to 700k, but I see the number going down sometimes, so there are situations where layout elements are deleted

TETYYS avatar Jul 23 '21 13:07 TETYYS

Is it maybe related to the amount of loaded animated images?

In your screenshot you have 1800 animated images, and my own count of 837 animated images puts my mem usage at 900 MB. image

You describe that you delete splits, and I get the same memory reduction behavior by closing them when I have a lot of animated images loaded by each split.

I test this by going into channels with a lot of animated BTTV emotes and opening up the emote window and my memory usage consistently goes up and stays that high until I close the tab: https://streamable.com/eqxqcn

KararTY avatar Jul 23 '21 14:07 KararTY

Yes I'm also experiencing this high ram usage. As noticed today, my ram usage was up to 1.6gb. After restarting, it dropped down to 600mb.

When I started testing it, I was on 400mb after a fresh restart with emote hover and link previews turned off. @KararTY suggested I open emote windows in all splits to load the animated emotes. I'm now at 944mb (this didn't change from me going afk):

image

ALazyMeme avatar Aug 11 '21 13:08 ALazyMeme

I went through all my splits today running the !bttvemotes command. I've been at home all day and had chatterino running. 390mb of ram being used. After running said commands, I'm now up to 1gb being used.

image

image

ALazyMeme avatar Aug 12 '21 10:08 ALazyMeme

I reached 1.5G of memory today

image

Mm2PL avatar Aug 14 '21 22:08 Mm2PL

1.83GB with lower statistics except drawing buffers chatterino_Sw1HUHFGiG

TETYYS avatar Aug 14 '21 22:08 TETYYS

~4.3GB, seen it sit around 5GB later on in the day.~ Ignore that, it's actually 526MB after 10 mins apu image

jupjohn avatar Aug 14 '21 22:08 jupjohn

Isn't most of the memory used because of the amount of images and animated images you have loaded into ram?

For example I start chatterino and it uses 60mb and then open the emote picker in zneix chat and memory usage goes up to 222mb. I expect this to be worse if you have a lot of tabs open and people use the emotes and sub emotes and if you have 7tv.

apa420 avatar Aug 15 '21 06:08 apa420

A little bit of a useless bump. IMO Chatterino should free unused images from memory but keep the cache and just reload from it. This could save us like half the usage of a high-uptime instance by my guesstimating.

Mm2PL avatar Aug 07 '22 10:08 Mm2PL

or memory map the files?

I have an instance right now that is on 3.23GB private bytes

TETYYS avatar Aug 07 '22 10:08 TETYYS

It might be worth doing something like unloading all emotes in a chat if you haven't looked at a split of that chat in the past 5 min or something similar. This approach might cause too much disk read though. Also might be very hard to implement, unsure.

Memory mapping might also be a good approach, but only really works if emotes have a lot of overlap between channels. I suspect the biggest issue are the animated emotes and do most channels have similar ones?

apa420 avatar Aug 09 '22 13:08 apa420

Memory mapping might also be a good approach, but only really works if emotes have a lot of overlap between channels. I suspect the biggest issue are the animated emotes and do most channels have similar ones?

While there are a lot of channel-unique animated emotes, a lot of the common ones are still shared across hundreds or thousands of chats. I suspect that this would make a pretty noticeable difference.

LosFarmosCTL avatar Aug 09 '22 15:08 LosFarmosCTL

Another possible optimization: instead of always pulling default for twitch emotes, could just cache static if the animateEmotes setting is disabled (tho extra logic is needed if the option is toggled)

iProdigy avatar Aug 09 '22 20:08 iProdigy

with PR #3915 I still have an instance with 1.78GB usage, process started 3 days and 9 hours ago 4 days and 5 hours ago: 2.02GB a week ago: 2.6GB chatterino_M3N4Foohhx

TETYYS avatar Sep 14 '22 22:09 TETYYS

with PR #3915 I still have an instance with 1.78GB usage, process started 3 days and 9 hours ago chatterino_M3N4Foohhx

keep it running and see how it increases :smiling_imp:

pajlada avatar Sep 14 '22 22:09 pajlada

I have reached 2.78GB with 11 days uptime before I wanted to play BeamNG.Drive so I had to restart chatterino

TETYYS avatar Sep 27 '22 14:09 TETYYS

We're more aggressive about releasing emotes now, closing this but feel free to re-open it if you feel like the latest nightly is still eating your memory like crazy.

pajlada avatar Dec 10 '23 12:12 pajlada