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

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:

UnityWebRequest www = UnityWebRequest.Get(uri);
yield return www.SendWebRequest();

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.

1 Like

Thank you for response. I already use this approach. Looks like some kind of hack, but it just works. :wink: