Stop the Twitter for Mac Image Cache Folder from Growing Huge

Aug 22, 2014 - 14 Comments

Twitter for Mac icon The Twitter for Mac client has a peculiar feature (bug?) which causes the app image cache to grow endlessly and without limitation. That means the Twitter image cache folder can easily become several gigabytes in size unbeknownst to the end user, and those cache files are also stored in virtual memory, which can cause unnecessary RAM usage and swapping on a Mac. Thus, if you use the Twitter app in OS X, you may want to manually intervene from time to time to delete this image cache, otherwise you’ll find your disk space slowly disappearing as the cached image files from your twitter stream get saved to disk, never clearing itself out. You also may get fed up with that manual cache deletion process and decide to prevent the app from saving any image cache, so we’ll show you how to do that too.


If you don’t use the Twitter app for Mac OS X this won’t apply to you, none of the other Mac Twitter clients have this issue. This is almost certainly a bug with the Twitter app, but it’s unclear if/when they will get around to fixing it with an app update.

The Location of Twitter Image Cache

The cache directory of profile images and embedded pictures from tweets is located at the following location in OS X (note the user library folder, not system library):

~/Library/Containers/com.twitter.twitter-mac/Data/Library/Caches/com.atebits.tweetie.profile-images/

Twitter for Mac image cache bloat crud

The easiest way to get there is with Go To Folder, accessible from the Finder “Go” menu and choosing “Go To Folder” (or hit the Command+Shift+G shortcut). Trashing the contents of that folder (not the folder itself) is sufficient to rid the problem, be sure you quit the Twitter app afterwards to unload all the cache from memory too.

Assuming you have the Finder Status bar enabled, you’ll immediately see how many files are sitting in this folder. If you’re a regular Twitter user you’ll probably find it to be well into the thousands, which is likely to translate into a notable amount of disk space.

Twitter image cache deleting tons of useless cache files

If you’re an active Twitter user who uses the livestream update feature and you’re going to be trashing this folder often, you may want to make an alias of it somewhere so that you can manually dump the contents, or proceed with the next step and just prevent the app from keeping all that junk around to begin with.

Preventing Twitter App from Saving Image Cache Files

Tired of manually deleting the cache files? Me too. You can prevent the Twitter app from being able to save all that cache by locking down the folder. This could theoretically result in increased bandwidth usage as each file has to be downloaded from servers again, so you would not want to do this on an internet connection with a strict data quota, like an iPhone hotspot plan. If you’re sure you want to lock down that folder and stop the image cache once and for all, here’s what to do:

  1. Hit Command+Shift+G from a Finder window and go to the following path:
  2. ~/Library/Containers/com.twitter.twitter-mac/Data/Library/Caches/

  3. Select the “com.atebits.tweetie.profile-images” folder and hit Command+i to ‘Get Info’ about that directory
  4. Check the box for “Locked” so that it’s enabled, then close out of the Get Info window
  5. Prevent Twitter for Mac image cache creation

  6. Quit Twitter.app, let it sit closed for a minute or so, and relaunch it (this is to dump the cache from memory)

You can watch the folder now and even with a very busy Twitter stream, no cache files will be saved into that cache directory.

Users who are comfortable with the command like could go with a more technical approach by implementing a symbolic link from the /com.atebits.tweetie.profile-images/ folder directly to the user Trash (at ~/.Trash/) or even to /dev/null/, but simply locking the folder form the Finder is sufficient to prevent the images being saved.

As far as I can tell, nothing in that “com.atebits.tweetie.profile-images” folder is essential to keep and deleting the contents will have no impact on Twitter or anything else. It’s possible that keeping a ridiculously large image cache could allow the app to perform somewhat faster when scrolling through ancient tweets, but to me that does not warrant the potentially large size of the directory.

The first time I came across the folder was with the help of OmniDiskSweeper, a great tool that scans a Mac hard drive for large files and folders, and it was found to be 8GB. On a MacBook Air with only 128GB of total disk space, that’s a considerable amount of wasted space for something that serves little purpose. I then started to empty the cache out manually once every week or so, and each time it’s somewhere between 1GB and 4GB, depending on the tweet activity for the prior week and how many pictures people embed in their tweets. Eventually I decided to lock down the directory, and so far haven’t had any problems with the app as a result.

.

Related articles:

Posted by: Paul Horowitz in Mac OS, Tips & Tricks

14 Comments

» Comments RSS Feed

  1. Louis says:

    Very nice. 688k files, 38gb freed!

    For anyone else struggling with deleting more than 131072 files, it’s not easy in Finder, and via the command line, if you try

    % rm ~/Library/Containers/com.twitter.twitter-mac/Data/Library/Caches/*

    You’ll receive “/bin/rm: Argument list too long.”

    Instead, you can use the find command with the delete option and watch them all disappear with great satisfaction :)

    Here:

    % cd ~/Library/Containers/com.twitter.twitter-mac/Data/Library/Caches/
    % find . -type f -print -delete

    Best of luck!

  2. Nilesh Parmar says:

    Nice tip thanks.

  3. @detoffol says:

    250K files and 16GB. That is a big bug.

  4. RandomPhoto says:

    Wow! Thanks very much for this tip – I had over 17,000 files in there, and just over 1gb of crap. Deleted it all, locked down the folder and it’s not filling up.
    Gotta share this one!

  5. Woody Carr says:

    Thanks for this tip! My cache had 5.69GB in 89,280 items.

  6. Greg Walters says:

    Needs a bug fix I think! Come on twitter ?!

  7. Viktor says:

    Thank you very much! I had 1GB Data to swipe.
    But I wouldn’t block the folder from writing, just make a crontab with cleaning folder half a year?!!

    • Paul says:

      That could be a good solution as well, but perhaps once a month rather than once every 6 months, at least if you have a smaller hard drive.

  8. DD0723 says:

    WOW!!!!!!!!
    I just cleaned mine and there was 3.71GB of crap images in there.
    Thank you soooooooo much for this article. I just got almost 4GB of space back!
    If we do this trick, will it cause any problems when Twitter actually comes out with a fix?

    Thanks again for this super article.

  9. I published a tip about this over at The Mac Observer back in April, saying essentially the same thing you did… and one of the commenters had an even better solution: use the Twitter > Empty Cache menu item. ;)

    So easy to miss we BOTH found the hard way of doing this! ;)

    http://www.macobserver.com/tmo/article/twitter-for-mac-icon-cache-using-disk-space

    • Paul says:

      Great minds think alike!

      After testing the native Empty Cache function, I found the username and password was dumped too… kind of an odd/annoying side effect.

  10. boblevel says:

    Thanks for this! I had no idea Twitter was wasting so much space on my HDD.

  11. Zed says:

    Wow. Emptied the cache, opened the app and there were 135 new files immediately. Have now locked the folder.

    • Paul says:

      I had the same experience, emptying it out repeatedly resulted in it filling up again very quickly. Locking it appears to be the best solution until Twitter issues an update.

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site