- Home /
WWW::Dispose doesn't work
Hello,
I'm developing the game for iOS with a lot of resources, and I'm using Asset Bundles to download most of resources after player has installed the game.
When user launches the game for the first time, I'm showing a preloading scene, and executing the code like the following in order to cache the asset bundles :
foreach (string assetBundleUrl in urls) {
WWW www = WWW.LoadFromCacheOrDownload(assetBundleUrl, 1);
yield return www;
www.Dispose();
}
For some reason www.Dispose() method doesn't clear the memory. So, caching many asset bundles makes my game crash on iPad 2.
Am I doing anything wrong? Or is this a known bug in Unity? Any ideas on how I could handle it would be helpful.
Thank you.
Where's WWW.Dispose
documented? I don't think WWW
has a Dispose
member.
I learned about downloading asset bundles from this page: http://docs.unity3d.com/Documentation/$$anonymous$$anual/DownloadingAssetBundles.html
Here using
keyword is used, but in comment it's written that using
keyword is a substitute for www.Dispose()
. By the way I tried using using
keyword, and it doesn't clear the memory too.
Answer by StormTeam · Aug 08, 2014 at 06:42 PM
We ran into a similar issue in our app. We were loading lots of textures from WWW and noticing iOS being the only platform to have a memory leak from it. We eventually found our solution here http://forum.unity3d.com/threads/www-memory-leak-ios.227753/. Basically, there is a known issue in unity 4.3 that leaks the data from www calls. This SHOULD be fixed in unity 4.5. In the meantime, you can follow Alexey's suggestion to modify the code in the generate xcode project or update to 4.5:
Essentially you need: search for extern "C" void UnityDestroyWWWConnection(void* connection) in WWWConnection.mm [delegate.connection cancel]; delegate.connection = nil; [delegate.data release]; // <-- ADD THIS [delegate release];will have the fix.
Your answer
Follow this Question
Related Questions
LoadFromCacheOrDownload non asset bundles 1 Answer
LoadFromCacheOrDownload Version Variable Reset? 1 Answer
Save Hash128 from Asset Bundle Manifest 2 Answers
AssetBundle, problem whit the version 0 Answers