iPhone app memory problems
by John F · in iTorque 2D · 01/16/2009 (10:11 pm) · 4 replies
My iPhone game sometimes terminates due to memory exhaustion. It is not clear to me why this is the case given that I allocate all game objects during game initialization and never knowingly delete or create anything afterward. Even so, sometimes the game plays for a long period with no problem and other times it will terminate several times spaced close together. If it is not a leak then perhaps I'm just using too much memory overall. However if this were the case I would expect more consistent behavior. I need to understand iPhone memory allocation better and how I might address the problem in iTGB. If anyone can help me with these questions it would be much appreciated.
1) My game uses a static sprite which I clone 81 times. Does each clone have its own copy of the PNG or do they share a single image in memory? I also use a single image to paint each tile in a tile map. Does each tile in the map have its own copy of the image in memory or do they share a single copy?
2) I use large images in some of my GUIs. How can I ensure that these are not loading until the GUI is made visible and and that they are unload afterward?
3) On the iPhone is the running application sharing memory with any other apps? Does termination of an application free any leaked memory?
4) For a given iPhone device will the application always have the same amount of memory available on launch?
5) Is there a way to ask iTGB how much memory it has allocated?
Any other tips about memory usage, allocation or leaks on the iPhone would be terrific.
Thanks,
John
#2
Using a super texture for tile maps or generally at all will result in lower performance than having distinct images at the time as you can't have cell images with pvr and not using PVR has a pretty bad impact on performance (I lost 5+ FPS by using a non pvr 512x512 for the tilemap instead of having distinct 128x128 pvr compressed images)
2) Don't execute things you don't need until you need them, then they won't be present
4) No. The available memory depends on what has been running before etc. As such its to assume that the answer to 3) is no too
5) No. Wouldn't make any sense as well. You commonly react to the warning you get from iPhone OS which notifies you when you enter the critical memory usage.
07/20/2009 (2:56 am)
1) 81 clones, until batching support is present, will by itself already be a problem, without texture dublication (which shouldn't happen).Using a super texture for tile maps or generally at all will result in lower performance than having distinct images at the time as you can't have cell images with pvr and not using PVR has a pretty bad impact on performance (I lost 5+ FPS by using a non pvr 512x512 for the tilemap instead of having distinct 128x128 pvr compressed images)
2) Don't execute things you don't need until you need them, then they won't be present
4) No. The available memory depends on what has been running before etc. As such its to assume that the answer to 3) is no too
5) No. Wouldn't make any sense as well. You commonly react to the warning you get from iPhone OS which notifies you when you enter the critical memory usage.
#3
Cheers
Mike
08/08/2009 (6:16 pm)
It seems that pooling objects will help to save memory on the device. But has somebody tested this before? Has somebody get a better performance on the iPhone after pooling objects?Cheers
Mike
#4
08/09/2009 (5:30 am)
Pooling does not save memory, but will raise the performance considerably if you create / destroy with a pretty high frequency.
Torque 3D Owner baylor wetzel