Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Loading obb (Android expansion file) cause huge allocation and crash

Discussion in 'Android' started by sebas86, Apr 17, 2019.

  1. sebas86

    sebas86

    Joined:
    Jul 1, 2013
    Posts:
    7
    Hi. I have problem with OBB on some low end devices. Application tries allocate huge memory block according to load OBB file and crash with classic error:
    Could not allocate memory: System out of memory!


    Is there any method to optimize loading OBB files? Google Play OBB Downloader plugin is not useful, it's outdated. Also documentation doesn't provide any hint how to implement expansion files in efficient way to avoid problems like this.

    Right now, application use regular GET web request:

    Code (CSharp):
    1. UnityWebRequest www = UnityWebRequest.Get(uri);
    2. yield return www.SendWebRequest();
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,722
    UnityWebRequest.Get will keep all downloaded content in memory, not suitable for large file.
    If you are on a recent enough Unity version, use DownloadHandlerFile. If you are on an older version that still doesn't have it, write your own DownloadHandlerScript.
     
    sebas86 likes this.
  3. sebas86

    sebas86

    Joined:
    Jul 1, 2013
    Posts:
    7
    Thank you for response. I already use this approach. Looks like some kind of hack, but it just works. ;)