- Home /
iPad real memory accumulation, how to prevent this?
Hi,
Currently running my app under Performance tools Activity checks and looking at the Real Memory entry.
It keeps accumulating as I load levels, Levels have more or less the same amount of textures and code, so why does the real memory accumulates. I don't load additive, I simply load a new level (Application.LoadLevel). The amount of gameObject not destroyed within the entire application is constant.
It seems that when a memory warning is issued, it cleans a bit , but it's never back to the start up value or anywhere close.
Am I missing something really obvious?
I though that Application.LoadLevel() was the best way to manage memory consumptions.
Thanks for your insight,
Bye,
Jean
Answer by Jean-Fabre · Mar 11, 2011 at 03:17 PM
Hi,
I found that loadLevel do not release assets properly for the garbage collector to to its work when needed, and in the troubleshooting page, they mentionned loadLevelAdditive as an alternative and it works reliably.
1- load an empty scene using loadLevel() ( a special scene with nothing in it) 2- load your actual scene additively using LoadLevelAdditive() 3- I just call UnloadUnusedAssets just to force things. it might not be required tho.
in effect, this equal loadLevel(), but now, the app is 100% stable and I don't get any memory warnings like when just using loadLevel() only.
Hope it helps,
Jean
This worked for me too. XCode was reporting that it was unloading hundreds of unused objects, but the Objects Now kept increasing with every level. It is still unloading a lot, but the Objects Now is staying where it should be - around 100-300. $$anonymous$$emory in use went from constantly increasing up to 5.9$$anonymous$$B to a stable 1.5$$anonymous$$B per level loaded.
Thanks!
Thanks $$anonymous$$! Just one more question if you don't $$anonymous$$d.
Do you load your special empty scene first and then you load your actual scene Additively from that empty scene (well not empty but with one GO with "Application.LoadLevelAdditive" script)?
Or do you load both scenes at once (from your current scene) like it is in the scripting reference?
// Loads empty scene
Application.LoadLevel ("EmptyScene");
// Add items from the level named "ActualSceneWhereIWantToGo".
Application.LoadLevelAdditive ("ActualSceneWhereIWantToGo");
Hopefully someone can make this clearer to me. Thanks!