- Home /
[iOS] AssetBundle.LoadFromMemoryAsync leak memory?
Hi guys,
here's the thing, we occurring memory leak on iOS (pointed by XCode monitor tool, screenshot attached) after each cycle of:
//lets assume that bundleData contains binary data of asset bundle, and that's temporary variable
1. AssetBundle.LoadFromMemoryAsync(bundleData);
[wait until load]
2. assetBundle = progress.assetBundle;
3. SceneManager.LoadScene("bundle_scene");
----------
//In some other method, after switching the scene to something other then "bundle_scene"
4. assetBundle.Unload(true);
5. assetBundle = null;
6. Resources.UnloadUnusedAssets();
Our findings:
When we replaced line 1 with: assetBundle = AssetBundle.LoadFromFileAsync(path) We not occurs any leaks, as long as bundle file stay uncompressed (otherwise LoadFromFileAsync was leaking too).
In our test project, leaks occures only if assetbundle contains AudioClip, which is used in bundled scene by object's AudioSource component.
This seems to be only iOS bug, similar code on Android not cause any problems.
We reported this as a bug to Unity team (even twice, first time on 23.12.2015 but with no luck... Or at least publication on issue tracker), so maybe someone of you guys experienced something similar? Any help will be appreciated, we run out of options here... We currently working with Unity 5.3.2f1, but same thing was also in previous version (5.2).
Ps. Here is test project, feel free to test this issue by yourself, maybe we missed something;) Testproject
Test procedure could look like this:
Build iOS version and use XCode debugging to monitor application memory usage. Press "Load bundle scene from memory" and "Go back" repeatedly. Notice that memory usage raise on each cycle, until the system kill the app due memory pressure.
[Edit - 29.02.2015] Confirmed as Unity iOS bug: issuetracker ticket