Tdesktop: huge memory leak in work with cached images and medium leak with loading images

Created on 22 Nov 2015  ·  34Comments  ·  Source: telegramdesktop/tdesktop

easy to reproduce

medium leak
1) clear cache
2) close telegram
3) run again
4) open group chat with 1000-1500 posted images
5) open task manager to see memory consumption
6) scroll up to earlier messages

huge leak
1) just close telegram after previous experiment (if it don't crashed lol) without clear cache
2) open group chat with 1000-1500 posted images
3) open task manager to see memory consumption
4) scroll up to earlier messages

i recorded video https://files.fm/u/ynvqtnms

bug help wanted

Most helpful comment

problem is still present

All 34 comments

I can confirm this behaviour on telegram 0.9.19 on Linux.

I can confirm too. I use Telegram 0.9.42 for Linux 64 bit downloaded from official site. But I also got confirmation from few people who uses it on Windows.

Open chat with stickers, images and other attached media files. Scroll to beginning of the chat and then to the end. Repeat several times and you could notice memory leak.

I left Telegram-desktop opened on my always-on archlinux machine for about 10 days without even touching that machine.
When i was back ,telegram was using about 2.5GB of ram and i repeat, nobody even used it.
This is still valid on 0.9.56

I used valgrind few months ago, but the amount of errors related to QT was a pain to debug properly.

Telegram Desktop slowly increases it's memory usage and never seems to clear it, until restarted manually or eaten by OOM Killer.

Hey there!

We're automatically closing this issue since there was no activity in this issue since 392 days ago. We therefore assume that the user has lost interest or resolved the problem on their own. Closed issues that remain inactive for a long period may get automatically locked.

Don't worry though; if this is in error, let us know with a comment and we'll be happy to reopen the issue.

Thanks!

(Please note that this is an automated comment.)

problem is still present

I confirm this bug exists on 1.4 and it leads to crash on 32 bits versions.

When are you fix this?

@Darkcacok It should be better in the latest versions.

Already 1.5 version and this bug is still not fixed on Linux. I do not know how it works in Windows, but Windows does not have the same problem

@Darkcacok Linux and Windows versions work the same way with images and caching, so there should not be any major difference. Maybe you test them differently?

I open the task manager on Windows and scroll through the chat. When the telegram begins to use more than 100 megabytes, the memory is reset to 50-60 megabytes. On Linux, memory does not even decrease, but only increases. What's the problem and how it is work?

@Darkcacok Do you try 1.5.2 on Windows? It should allow up to 128 MB of image data in memory before it starts clearing, both on Windows and on Linux.

Ok. I tried version 1.5.2 on windows. Now the memory is kept at around 200 megabytes, but it is still slowly increasing. I managed to reach 230-240 megabytes. On Linux, memory cleanup does not work at all.
image

image

So why on Linux it does not work?

I'm so sorry. Memory is really cleared on Linux. But not as aggressive as on Windows. I was not able to increase my memory usage by more than 1 gigabyte. Good work. But you can do better.
image

1.5.15 on Linux. Tdesktop use to eat 50-60 mb on startup but after ~24 hours memory usage increases up to 300 mb

Man, this issue is opened for more than 3 years now.
I doubt it will be solved, so i just made a script that restarts it every hour.

#!/bin/bash
while true ; do
kill `pidof telegram-desktop` && telegram-desktop -startintray &
sleep 3600
done

...and made it a systemd user service

@kokoko3k oh, it's really straightforward solution thank you.

But it's sad that the memory leaking is not in the priority for developers. Where are the benefits of native app? It uses as much RAM as Electron does

@danielleontiev that's false @john-preston already fixed few big memory leaks, now it's really hard to use >1GB of ram

@Aokromes I've seen this just now. Yes, maybe 1Gb is unreachable but 400 Mb is still too much

I've opened tdesktop on linux for a month and it consumes 15GB memory. It still has some memory leak issues under the hood.

In case someone knows how to fix, debug build 1.8.13 running under ubuntu linux x64

https://gist.github.com/37b7ee627100c703518b6586a1ed9713

Screenshot_20191219_092636
Left my PC on for night and got this beauty today's morning :face_with_head_bandage:

After updating from version 1.9.3 to 1.9.5 my telegram app consumes ~130 MB of RAM instead of ~3 GB on 1.9.3.

Starting of application require 1-2 sec now vs ~10 seconds on 1.9.3.

maybe fixed by 5f5d562

I think this only works for "GIF". What about the photo?

Sorry my "English".

2.0.1 version telegram
Mac OS High Sierra 10.13.6 (17G65)

30 min usage:
image

I off in settings:

  • smiles, animations, autoload all files/images

I clear cache

Restart telegram

Slow scroll messages - high load RAM (Unlimited. RAM not clear. Sometimes, 30 min usage telegram = 10Gb RAM).

Video - https://cloud.mail.ru/public/5ie4/5MgambzAK

up?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  ·  106Comments

AliDjango picture AliDjango  ·  109Comments

armanatory picture armanatory  ·  89Comments

meness picture meness  ·  96Comments

auchri picture auchri  ·  149Comments