signalapp / Signal-Desktop

A private messenger for Windows, macOS, and Linux.
https://signal.org/download
GNU Affero General Public License v3.0
14.62k stars 2.66k forks source link

Memory Leak when switching conversations on 1.40.1, MacOS 11.2.x #4808

Open sgreadly opened 3 years ago

sgreadly commented 3 years ago

Bug Description

Hi,

I noticed Signal App v1.39.4 on Mac Mini, Big Sur 11.1 (20C69), seems to be leaking memory at a fast rate when you switch from one conversation to another.

While writing this, it was around 1.4GB, and now it's up to 1.7GB.

The best way I can reproduce this, is when I switch between the group conversations I have (possibly all chats including individual ones too). I.e., click on the next conversation, and memory climbs up. Then 3rd, climbs again, 4th, etc.. click on 1st again, still climbs even more.

I found a few similar bugs but they're either closed, or on older versions / different platform.

Steps to Reproduce

  1. Click on one conversation
  2. Click on another
  3. Keep doing that.

Actual Result:

Memory leaks around ~10-90MB per iteration.

Expected Result:

Memory to not leak or climb continuously.

Screenshots

Screen Shot 2021-01-13 at 4 40 58 PM Screen Shot 2021-01-13 at 4 41 04 PM Screen Shot 2021-01-13 at 4 41 07 PM Screen Shot 2021-01-13 at 4 47 29 PM Screen Shot 2021-01-13 at 4 48 10 PM Screen Shot 2021-01-13 at 5 02 31 PM

-->

Platform Info

Signal Version: v1.39.4

Operating System: Mac Mini 2014, Big Sur 11.1 (20C69)

Linked Device Version: iPhone XS Max, iOS 14.3, running Signal 5.1.0.31

Link to Debug Log

https://debuglogs.org/465d352c490af66a0f09cf278c5e9152cdcee98a35875fe636d05f0f98261114

Edit: up to 1.81GB now.

Let me know if you need anything else. Ta.

chiraag-nataraj commented 3 years ago

I see similar behavior on Debian (x86_64) running Signal-Desktop 1.39.4. Does switching conversations also become slow?

sgreadly commented 3 years ago

I see similar behavior on Debian (x86_64) running Signal-Desktop 1.39.4. Does switching conversations also become slow?

Sluggish, yes.. but it's an old-ish Mac Mini with limited resources anyway ^_^

EvanHahn-Signal commented 3 years ago

Thanks for reporting. We'll take a look.

For what it's worth, I've looked into this a few times and was unable to find any obvious culprit. In fact, I noticed memory go back down after the garbage collector ran, which can sometimes take a long time. But I know we have memory leaks somewhere, and this is a helpful lead.

sgreadly commented 3 years ago

I can see garbage collection in effect mainly with the Steam Helper (Renderer). That climbs up several hundred megs when you're scrolling through the history of a conversation, and eventually drops down (good!).

Edit: I noticed a notification for v1.39.5 so I upgraded & restarted. Signal daemon also still leaks at a slow rate when I switch between conversations. Around 1MB - 50MB per iteration.

Currently sitting at 510MB usage. Edit: 620MB.

Not sure if it helps, but here's a sample from yesterday's around 1.5GB, and now around 520MB.

Sample of Signal v1.39.4.txt Sample of Signal v1.39.5.txt

If there's anything else I can provide let me know. Hope this helps and thanks for your support!

UltraWelfare commented 3 years ago

Tried on Arch and it really goes up when rapidly switching between conversations up to 5-8mb per switch. But after some time the GC kicks in and removes most of it... I tried recording a memory snapshot with the developer tools and I didn't find anything suspicious in terms of a memory leak...

sgreadly commented 3 years ago

Good to know!

I have a feeling, either GC isn't kicking in for OSX, or it's not properly doing what it should be doing :/

I hope devs have enough info in this report to narrow down or isolate the issue.

UltraWelfare commented 3 years ago

Good to know!

I have a feeling, either GC isn't kicking in for OSX, or it's not properly doing what it should be doing :/

I hope devs have enough info in this report to narrow down or isolate the issue.

Using the App for a day or so and I'm switching conversations but the app always stays ~300-500MB max... I'm not sure if it's a bug only recurring for Mac from the electron side or the Mac side. Definitely needs some more investigation and reports to see if other people have problems too.

sgreadly commented 3 years ago

Just to confirm, this seems reproducible on an M1 Macbook Air, with 1.40.1.

I had a hunch earlier if maybe this was related to the old conversation version, but I recreated them to the new conversations and still have the same leak.

This happens with both 1-1 and group conversations, when switching between them.

ghost commented 3 years ago

Hi, I can confirm high memory usage. Big Sur 11.2.3, Apple M1, Signal 1.40.1: image

starvational commented 3 years ago

I'm also on Big Sur 11.2.3 and seeing high memory utilization >1GB. Mac Mini (Late 2014). Signal v1.40.1 Screen Shot 2021-03-21 at 11 13 55 AM

therealtomg commented 3 years ago

Also here to confirm high memory use, I'm on Big Sur 11.2.3 - 15-inch MacBook Pro 2017. Signal v.1.40.1.

Screen Shot 2021-03-22 at 9 18 58 am
chiraag-nataraj commented 3 years ago

I can reproduce fairly easily just through normal use, and this is on Debian sid/experimental. What should I capture and post here once I see it happen again? @EvanHahn-Signal, if you can tell me what I should share in order to help pin this down, I can provide whatever information you need, since this happens quite regularly for me.

[edit] Desktop version: 5.0.0 Linked device: Samsung Galaxy S7, Android 8.0.0, Signal version 5.7.6.

chiraag-nataraj commented 3 years ago

@EvanHahn-Signal, Signal-Desktop is currently using 23% of my RAM according to htop, and based on cgroup statistics (I run signal-desktop through a systemd unit), it's currently using 3.9GB.

What can I provide to help debug this? I'm running release as I mentioned in my comment above.

EvanHahn-Signal commented 3 years ago

We've spent a lot of time trying to find these memory leaks but don't have a clear reproduction. Are you able to reproduce this by switching conversations repeatedly? Or is it something else?

sgreadly commented 3 years ago

@EvanHahn-Signal

Yep. Simply switching from one conversation to the other will trigger the leak. The more you do, the higher it gets.

I can still repro this on Signal App (Mac) v5.0.0. Refer to earlier comments of mine for more details if it helps.

Edit: Would having a debug version that provides more info help?

Ta.

chiraag-nataraj commented 3 years ago

We've spent a lot of time trying to find these memory leaks but don't have a clear reproduction. Are you able to reproduce this by switching conversations repeatedly? Or is it something else?

I only need to switch conversations a few times. Literally just normal usage --- chat with one person for a while, switch to another convo as a notification comes in, chat with them, switch back, etc --- is enough to reproduce this.

Right now, my signal-desktop has been running for just over 5 hours and is sitting at 1.7GB RAM usage according to systemd (which uses cgroups to track memory and CPU usage).

chiraag-nataraj commented 3 years ago

@EvanHahn-Signal Is there any way for us to extract extra information? I don't think the debug log would have the required info, and the developer console has been disabled in newer builds iirc. So is there no way we can provide more insight (beyond 'reproduction' steps, which seems to simply boil down to 'use Signal as normal', at least in my case)?

starvational commented 3 years ago

We've spent a lot of time trying to find these memory leaks but don't have a clear reproduction. Are you able to reproduce this by switching conversations repeatedly? Or is it something else?

I don't know if it helps, but maybe the leak is triggered after some time of running in the background or just running in general (e.g. some background service). I leave signal running all the time on my Mac, either focused/visible or in the background when I close the app to hide it. I probably go weeks before having to reboot my Mac and the leak isn't apparent immediately from what I've noticed but it may be different for others. Anyhow, once I notice that utilization his high, I can echo that switching conversations ramps up the RAM consumption noticeably.

sgreadly commented 3 years ago

I don't know if it helps, but maybe the leak is triggered after some time of running in the background or just running in general (e.g. some background service).

Nah. I tested that. I can close Signal and start it up again. Then start switching between conversations and instantly memory starts to rack up.

Sometimes it stays around a point (not increase any more). Then you just leave it for say 10 min and start switching conversations again and it'll jump in memory again.

sgreadly commented 3 years ago

I don't know if it helps, but maybe the leak is triggered after some time of running in the background or just running in general (e.g. some background service).

Nah. I tested that. I can close Signal and start it up again. Then start switching between conversations and instantly memory starts to rack up.

Sometimes it stays around a point (not increase any more). Then you just leave it for say 10 min and start switching conversations again and it'll jump in memory again.

sgreadly commented 3 years ago

I don't know if it helps, but maybe the leak is triggered after some time of running in the background or just running in general (e.g. some background service).

Nah. I tested that. I can close Signal and start it up again. Then start switching between conversations and instantly memory starts to rack up.

Sometimes it stays around a point (not increase any more). Then you just leave it for say 10 min and start switching conversations again and it'll jump in memory again.

sgreadly commented 3 years ago

I don't know if it helps, but maybe the leak is triggered after some time of running in the background or just running in general (e.g. some background service).

Nah. I tested that. I can close Signal and start it up again. Then start switching between conversations and instantly memory starts to rack up.

Sometimes it stays around a point (not increase any more). Then you just leave it for say 10 min and start switching conversations again and it'll jump in memory again.

sgreadly commented 3 years ago

I don't know if it helps, but maybe the leak is triggered after some time of running in the background or just running in general (e.g. some background service).

Nah. I tested that. I can close Signal and start it up again. Then start switching between conversations and instantly memory starts to rack up.

Sometimes it stays around a point (not increase any more). Then you just leave it for say 10 min and start switching conversations again and it'll jump in memory again.

sgreadly commented 3 years ago

I don't know if it helps, but maybe the leak is triggered after some time of running in the background or just running in general (e.g. some background service).

Nah. I tested that. I can close Signal and start it up again. Then start switching between conversations and instantly memory starts to rack up.

Sometimes it stays around a point (not increase any more). Then you just leave it for say 10 min and start switching conversations again and it'll jump in memory again.

sgreadly commented 3 years ago

@indutny-signal , Just to confirm, this issue still exists.

MacOS Monterey 12.0.1 (21A559) (and Big Sur too)

Signal 5.22.0

After a few hours of usage - mostly switching between conversations as per issue description.

Screen Shot 2021-10-30 at 2 25 03 PM

Keeps climbing and does not go down.

sgreadly commented 2 years ago

I had to restart today due to an update (5.23.0). But with minimal usage this week, it went up to ~1.8GB before I restarted.

Screen Shot 2021-11-04 at 11 58 31 AM

sgreadly commented 2 years ago

I could really appreciate an update to this. It's still plaguing and I have to restart Signal app once / twice daily as a result.

sgreadly commented 1 year ago

FYI Issue is still reproducible with v6.26.0 on MacOS 13.4.1 (c) on Apple M1.

Simply switching randomly between conversations for about 2 minutes bumped memory usage to 1GB, and it's now hovering there, not going down.

jamiebuilds-signal commented 1 year ago

@sgreadly Are you still experiencing this in the latest version of Signal, could you provide a debuglog if so?

sgreadly commented 1 year ago

Hi @jamiebuilds-signal ,

I just tested it on 6.27.1 and in ~4 minutes of switching between the conversations, memory usage jumped to ~850MB. The good news is it doesn't seem to go higher than that. But I'm not sure if maybe that's because of the amount of data currently in the conversation that needs to be loaded?

I.e., if I had more content in my conversations would it go higher or not.. Not sure.

https://debuglogs.org/desktop/6.27.1/ae92b1e292be7c21cda549a6ab915710c418c91f6c03638c9ea41e523b8490a6.gz

It's now staying around 750MB after I stopped. Compared to ~$180MB after restarting.