Tdesktop: Too many cache files

Created on 30 Aug 2016  ·  23Comments  ·  Source: telegramdesktop/tdesktop

I find a very large amount of files in the tdata/ directory:

% ls -l ~/.TelegramDesktop/tdata/D877F784D5D4EF8C | wc -l
20042

They seem to be binary, so I don't know what they are for.
Does the app really need over 20000 files, or are they created by a bug?

% find ~/.TelegramDesktop | wc -l
21311

It's over a 1000 other files as well, but I guess that's a fair amount of image cache?

bug

Most helpful comment

Having something growing indefinitely until a very unlikely action sounds like a bug to me.

The only other reason to "log out" would be that you have two telegram users and want to switch?

(_Restarting_ the client does nothing to the amount of files other than creating some more files.)

All 23 comments

@Mirarkitty All this is some cache / drafts files. If clearing doesn't remove them, you can try to logout-login back.

"Clearing"?

Shouldn't Telegram keep this relatively clean by itself without any user action?

@Mirarkitty Well, desktop cache is just growing up till logout.

Hm, having an option to remove items from cache after some time like on iOS would be nice...

Having something growing indefinitely until a very unlikely action sounds like a bug to me.

The only other reason to "log out" would be that you have two telegram users and want to switch?

(_Restarting_ the client does nothing to the amount of files other than creating some more files.)

There's a "clear cache" button on the Desktop Client, settings page. On android (and I believe iOS), you should be able to clear the app cache with onboard tools?

Also it's worth to mention that cache files should be stored under a directory specifically designed for it - $XDG_CACHE_HOME / $HOME/.cache

While on the topic of Cache: how hard would it be to either specify a Size or Time Limit for the local cache? (ideally, on PC and mobile...) i.e. Keep the most recent 300MB worth of cache, or keep the Images of the last 7 days or something?

I'd also like to be able to store the cache separately on a RAM drive, I don't care much if it gets cleared on reboot. Obviously the login data in that case should be stored elsewhere permanently.

There's a "clear cache" button on the Desktop Client, settings page. On android (and I believe iOS), you should be able to clear the app cache with onboard tools?

I had a 12GB cache, and tried this "clear cache" button, it brought it down only to 10GB - a few hundred MBs only.

Logout/Login brought it down to 4GB. [thumbs up emoji]

How to bring the cache down to 100's of MBs total, max 1-2 GBs? Can I delete the files in tdata directly?

I had 375,554 files in that folder, local storage option was showing 81k images. After clearing cache from telegram it deleted those 81k files(that was from past 5-6 months). Local storage is showing that the cache is cleared but I still got 290k+ files(~3gb) in that folder. So basically I still got files from 2015 onwards.

Logging out of telegram had no effect so I had to delete them manually.

P.S I am on windows.

I'm seeing 124k files in there, up to 2.8GB. This is crazy for an SSD drive, with no configuration option to get that cache smaller. The said "Local Storage" option tells me I have 3.4k of images, up to 35MB of files. And I don't want to relogin as that will clean up stuff that should never be cleaned up in the first place, such as recent emojis and stickers.

It is, actually, a PITA to see my login being lost after a crash and having to keep digging for the emojis I use the most. I would never log out to clean up that folder, and it's taking more space in my system than any other aplication alone. _just for messaging_.

C'mon guys, this is sitting here for more than a year already.

Definitely have to add an adjustable limit on the desktop cache size. Mine got up to 18bg and after using the clear cache button it only cleared just under 1gb. It would be better to be able to set a max limit this way suddenly you don't find your out of space on your C drive.

It would be nice to have a button "clear cache" that really works, an option to sex maximum size and an option to choose where to store this data.

The portable version saves cache on the same place where the app is installed. That's great cause my system drive is a small ssd. Telegram now resides on the big hdd.

Just realized I have 11GB in the cache, hitting clear cache didn't seem to do the trick at first but turns out it was just deleting them at a ridiculously slow pace. Logging out didn't seem to affect the cahe at all either (just removed my background picture) and closing the app halted the deletion process.
Now it reports to have nothing cached even though there's 10GB of it, like mUsama described.

I too think that having an option to limit cache size is pretty important, but even without it, a clear cache button that actually works is even more critical.

Is it safe to delete the entire folder content manually? Are there any files I should watch out for?

@Nayelianne You can logout, delete it and login back again.

Currently my cache (local storage) amount is very reasonable (under 1GB total).
So I'm definitely not complaining since it shows a breakdown of what that data is.

Maybe some age information could be useful? Is there settings for when to clean old files?
Being able to adjust when to clean old files, would be useful to a user and I'm guessing would erase the need for this topic.

I agree, there should be some way to clear the cache through the application if it doesn't handle it itself. I was pretty surprised to discover 6.5GB of cache files (which given they are not in a folder called "cache" means I have been backing that up nightly)

When I used the clear cache option in the app it was reporting only around 200MB of image files.

I logged out and it didn't appear to do anything, then slowly the folder size started to decrease (10 min and currently at 4.5GB, so it will take a little while)

I am a big fan of the option in the mobile app to set the amount of time to "keep media".

edit: 14 min later and we are down to a respectable 1.7MB

I cannot believe this is still an issue.

My notebook had 5 gigs of this cache recently. Quadruple the amount Skype generated in few years!

Mobile apps clear the message DB to only host recent messages, shouldn't Telegram do the same? Will this solve A LOT of hangs where it just blocks the UI while reading another batch of this ENORMOUS cache from disk?

I know the UI blocking on I/O is more of a QT problem (AMD apps have this too), but at least try to mitigate it by keeping the cache size reasonable! Even with thousands of messages there's no reason for it to be this large.

@OneCrazyRussian You're right, it should be done better.

For those interested, this is just an easy workaround for Linux to delete files older than the specified date. From the tdata directory, run

find . ! -newermt 2018-05-01 ! -type d -delete

Be aware that it may also delete some settings, so use at your own risk.

fixed somewhere on 1.3 no?

Was this page helpful?
0 / 5 - 0 ratings