views:

492

answers:

3

Hi,

I am currently developing an iPhone game that has numerous animations using image sequences (jpg and png with transparencies). Using Instruments to view Leaks and Object Allocations, the most I've seen the object allocations go up to is less than 500k. However, the program still crashes and quits unexpectedly when we switch from one level of the game to another. Is this abnormal? From what I've read, the iPhone has 128Mb of memory.

More info: We are using CAKeyFrameAnimation (as adviced by Apple) and imageNamed (so that the images are pre-cached). In each Level object, I can see that the dealloc is getting called when I swap one level out and load another. However memory seems to keep going up and up and never gets released back down to its original level. =(

+1  A: 

This question may be of help Dispelling imageNamed FUD.

Regarding the iPhone having 128mb you may want to check the last few posts at gamesfromwithin.com (by Noel Llopis) regarding the actual amount of RAM you're likely to see in your app (the OS / mail / iPod apps using slightly more than expected currently!)

barog
Cheers, just read that page myself.Ah yes, I actually knew that you don't actually get all 128MB to play with. From what I've read tonight...you get roughtly 22MB.Got a reply on another forum and I might be using the wrong tools. Going to check out "memory or activity instruments" tomorrow.
Ben X Tan
This article is great: http://gamesfromwithin.com/?p=428
Ben X Tan
Btw, thanks for the link barog.Just tested with Activity Monitor. Memory was through the roof! 30MB+That was with 36 frames of jpg full screen images using CAKeyFrameAnimation and imageWithContentsOfFile.So I've killed that particular animation for now and we're investigating using a movie with a subview overlayed on top for the buttons. Will post results when we have them.
Ben X Tan
+1  A: 

I posted some tips on this exact problem in the comments to this question:

http://stackoverflow.com/questions/846458/iphone-animating-frame-rate-and-number-of-frames/850061#850061

Ramin
A: 

hi you can use the autorelease for it and call an explicitly function to release the unused image view by which image allocation will be low and when the delloac function will be called you already have done some work by relaeseing them explicitly so when delloc call it will freeup mostly of the memory try this one.

thanks