Memory Issues of 2D app

I am newer of Unity iPhone.

I have met lots of memory issues:

1/ I made an app which use only GUI scripts to show some image, I used "Private var " definition to my texture var that show image in my script, but I found memory never released when I update new texture to var:

private var myTexture : Texture;

Finally, after dozen image loaded, app used over 50M memory and my iPhone crashed (same result every time) (Each picture only 320x480 as iPhone screen size)

2/ So I created a new scene which only has a empty object in it, I added nothing to this object, and build the scene, I found the app still use 13M memory of my iPhone,

3/ My app always use high level of CPU , is it related to “Update” function or “OnGUI” function ?

is that normal? or I have to do something in project setting to make it more effective?

BTW, I tried “Destroy” texture before load new one, but nothing changed. Memory allocated still increased.

Sorry for my poor english.

thanks

textures are not garbage collected.
if you replace them at runtime and don’t switch levels you need to use the CollectUnusedAssets function from the application class.

320x480 does not exist.
such images are extended to 512x512 and will lose compression, making them up to 16 times as large as needed.

  1. thats correct, thats the base size of unity + mono with iPhone Basic

  2. Both and both should be only be used where really required, especially extensive calls to ongui.
    optimally you would enable the profiler though then you get meaningfull data whats eating the time.

:smile:

Thanks for your reply.

1/ problem resolved and bugs fixed, now it only under 35M and rarely crash.

2/ CPU issues remains, but mostly 50%-70%. I can not cut down the use of CPU although there are only some buttons in OnGUI (I keep update() empty when I was debugging)

According to textures, what I need is full screen image which ratio should be 2:3, but if I use image like 128x128 or 256x256, how can I make it correct ratio size?

Thanks,