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.

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:

4.5 will have the fix.
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];