Search Unity

Android Cache Growing with Unity Ads

Discussion in 'Unity Ads & User Acquisition' started by Grawnya, May 14, 2019.

  1. Grawnya

    Grawnya

    Joined:
    Apr 5, 2018
    Posts:
    9
    Hi Everyone,

    On releasing my app and testing on my Android device, I notice that every time a video ad shows, the app's cache grows. I believe this is to be expected because ads are cached.

    But what happens when the cache fills up? I believe 50 GB is allocated. Should there be some code in my app that can check the cache and empty it if it is nearly full? Or will the underlying Unity code take care of this situation? In which case I shouldn't do anything.

    I have found this function ClearCache. Should I always call this on exit so that the cache never fills?

    https://docs.unity3d.com/ScriptReference/Caching.ClearCache.html

    Is this recommended practice? Is it dangerous to clear the cache while the app is still running - even though it's executed just before shutdown?

    I'd like to know how other people handle this issue.

    I'm building with Unity 2018.3.13

    Thanks a lot
    Grawnya
     
  2. DenisasK

    DenisasK

    Unity Technologies

    Joined:
    Oct 13, 2016
    Posts:
    89
    Hello, Unity Ads taking care of the cached files during init. If the cache size is bigger than 50mb, it will be cleared during init.
     
  3. Grawnya

    Grawnya

    Joined:
    Apr 5, 2018
    Posts:
    9
    Hi, that's good to know - thanks a lot for the reply.
     
  4. Beebaa

    Beebaa

    Joined:
    Dec 30, 2020
    Posts:
    6
    This is a late reply, but Unity Ads doesn't clear its cache in my app, when it exceeds 50MB. My Apps size is approximately 60MB, but with Unity Ads it easily reached a total size 200MB until I cleared the cache manually. Just one ad increased the size by about 22MB. Can I clear the Unity Ads cache by code somehow?
     
  5. NoSkinPotato

    NoSkinPotato

    Joined:
    Jul 20, 2023
    Posts:
    1
    I'm currently suffering the same problem. I know it's been a while, but did you find the solution by any chance?