- Home /
Memory warning and crash in iphone using assetBundle
Hi.
I'm using assetBundle to download all the required textures in my DLC. Once the user buys the content the download starts, about 60 textures in various sizes. The download works flawessly in Unity enviroment, but in the device receives a memory warnign and then crashes, so:
- I'm using an different AssetBundle for each texture, each assetBundle is being downloaded in sequence, one at the time, would it be better if I used a single AssetBundle for all the textures ( just about 2.6 MB in total).
- After downloading each texture I instantly assign it to a material...this impacts my avaliable memory ?
- What can I do to download all the content without memory warnings and crashes ?
- I'm supossed to somehow release or free my asset bundle ?
Thanks !
This is my chunk of code, being called for each assetBundle:
public IEnumerator LoadTexture(string packageName, string materialName) { staticDownloads++; int downloads= staticDownloads;
WWW download = new WWW ("http://www.mywebsite.com/MYGAME_DLC/"+packageName);
yield return download;
AssetBundle assetBundle = download.assetBundle;
Texture2D go= assetBundle.mainAsset as Texture2D;
Material mat= Resources.Load(materialName) as Material;
mat.mainTexture= go;
if (!go) Debug.Log("Couldn't load "+ packageName );
}
Not making as an answer, but so far I have yet to see a properly working garbage collection on iOs with Unity or else I am missing the obvious regards making sure I release correctly an asset. Check this answer for a work around ( http://answers.unity3d.com/questions/44484/ipad-real-memory-accumulation-how-to-prevent-this ). I would simply not download 60 textures and find a way to show thumbnails, or stream or constraint your interface somehow into a finite pool of textures thyt you know doesn't lead to crashes
Your answer
Follow this Question
Related Questions
How to import the object from server to unity 2 Answers
Failed to Wait on a Semaphore 2 Answers
Iphone downloadable content restrictions 1 Answer
Animator in assetbundle from iphone app not play 1 Answer
Assetbundle can't load in IPhone 1 Answer