I have built a game I have been working on for Android (Unity). It's a simple game: air hockey. It weights 21mb with all the assets and scripts.

After playing for a bit I have noticed that cache of the game is growing very fast and probably infinitely (to use all phone memory). The game itself takes 43.20mb installed. But cache for me right now is 80mb.

I have similar games installed and they take up to a 6mb max. And definitely, the cache is growing slower for them.

Previous games that I have developed doesn't have this issue. For example, the game that takes 80mb disk space has only 532KB of cache and it's not growing.

I thought of manually clearing the cache every time player leaves the game. I haven't found any relative information on how to do that in unity, but that is probably even not the right way to do it. All I have found is how to delete GI cache... and the google search doesn't show anything relevant.

How can I track what is creating so much cache? Is there an easy way to do it within Unity? Or how can I request cache deletion from code?

  • 1
    \$\begingroup\$ If your edits have solved your problem, please feel free to post them as an answer that you can later mark Accepted. :). Just don't clear your cache too aggressively — lots of phone users have more storage than data bandwidth in a month, so when an ad can play from cache instead of re-downloading that can be kinder to their data plan, even if it costs a bit of revolving storage. \$\endgroup\$ – DMGregory Oct 11 '17 at 13:43

I have done some intensive testing and figured out that cache grows only before UnityAds show. It can grow earlier than ad is displayed. Then I have done some searching and unity ads do cache video ads inside internal storage. But how to prevent it from doing it? I haven't found any information on this yet, as soon as I find some I will post an edit.

You can delete cache using Caching.ClearCache(); inside Unity - it will delete all the cache created by the application.

It's weird that UnityAds don't have auto-deletion of cached ads. But maybe it's for the better, so that developer can control the process.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.