- Home /
Asset bundles using double memory!
Hi, we are making quite a large IOS game and have recently run into memory problems. The main issue is we were using resources to load everything but this means that the memory isn't released after the object is destroyed! we moved onto using asset bundles to load some of the main objects so we can control the memory and release it after the object is destroyed. This works but there is a massive drawback, the Asset bundle uses double the memory!! we have tried to release the bundle and not destroy the objects after instantiation but this has the same issues and resource loading. Has anyone had the same issue? is there a way to use asset bundles but not double the memory??
Thanks
please post an example of you asset loading code.
I think I know what the problem is, but I need to see the code to make sure.
Ah nice one! this is the function we use for loading
private IEnumerator ReloadBundle( string _bundleName ) {
isLoading = true;
string file = "file://" + bundleFolder + "/" + _bundleName +".unity3d";
WWW www = WWW.LoadFromCacheOrDownload (file, 1);
yield return www;
AssetBundle bundle = www.assetBundle;
if (bundle != null) {
string bundleFile = Path.GetFileName (file);
string bundleExtension = Path.GetExtension(bundleFile);
string bundleName = bundleFile.Substring(0, bundleFile.Length - bundleExtension.Length);
if (!bundles.Contains$$anonymous$$ey (_bundleName)) {
bundles.Add (_bundleName, bundle);
}
else {
bundles[bundleName] = bundle;
}
//Debug.Log("Size before: " + sizeof(www.bytes) );
www.Dispose();
//Debug.Log("Size: " + sizeof(www.bytes) );
www = null;
}
isLoading = false;
}
Let me know if there is any other info you need
thanks
hmmmm... I thought you where missing the www.Dispose, but I see you have it.
Can you explain what do you mean by "double the memory"?
How to do know it's double and not the normal size?
Ah i see, well we have a memory profiler and can see the actual memory stats in game and the memory is double when using asset bundles. The memory gets released properly when we unload the bundle with the true flag set but it isnt much help if the memory is double to sart with.
Did you find something? I am facing the same problem. I will check the thing with www.dispose thou. A 40$$anonymous$$B Bundle covers 150 $$anonymous$$B RA$$anonymous$$ (explorer with $$anonymous$$AT)... Dont know why...
Answer by milox777 · Jun 14, 2014 at 10:23 AM
Try to use: bundle.unload(false) at the end of 'ReloadBundle' method.
Your answer
Follow this Question
Related Questions
Memory Allocation Continues to Grow? iOS. 4.6.3 0 Answers
AudioManager memory usage on iOS when using Asset Bundles 3 Answers
I have this out of memory issue when running my webgl game in iOS. 0 Answers
Is there a way to release Mono memory on iOS? 0 Answers
Unity Sprite Memory Usage Is Huge 1 Answer