I have just signed up for the paid developer program so today has been the first day I've been able to try my almost completed app on a device. The app runs perfectly on the simulator, and my iPhone 4, but it doesn't run at all on my iPod touch (i think its third gen, its the one before the latest one). Is it a memory problem? My app is pretty simple, the only reason I could think there might be a memory problem is that I have an animation (NSArray) with about 50 images.
If your code is optimized well then it shouldn't be a problem. Also, if memory was low your app would receive the didReceiveMemoryWarning message (which you definitely should look for and heed the warning).
There's also a neat little app in the documentation that demonstrates memory efficiency in such an app Loading
How big are the images? They have to be uncompressed at display time, so 50 screen-sized images would be 320 * 480 * 50 * (4 bytes) = 29.296875 megabytes, which is too much for your poor iPod. Use fewer images, or only load them a few at a time.
Also use leaks an allocations to make sure you're not leaking or hoarding memory.
How big are the images? They have to be uncompressed at display time, so 50 screen-sized images would be 320 * 480 * 50 * (4 bytes) = 29.296875 megabytes, which is too much for your poor iPod. Use fewer images, or only load them a few at a time.
memory.
Thanks for the reply. The total animation size is 1.9Mb (the images are mostly empty space) so i'm not sure how that could be a problem. How ever I do have the NSArray displaying the images at 24 frames a second so I'll have a play around with that.
The total animation size is 1.9Mb (the images are mostly empty space)
Is 1.9MB the size of the compressed .png files, or the uncompressed size after loading? It's the uncompressed size that matters here. I think you're talking about the compressed size since you mentioned empty space.
Going from a logic perspective, if the app works on the simulator, and the iPhone 4, but not the iPod 3, the problem must be a difference in capabilities between the devices. It can't be the phone/text capabilities, because the simulator doesn't have them either. Your computer and iphone 4 have a lot more memory than the ipod 3, and therefore it is most likely a memory problem; if the only memory-intensive thing you have on the device is those images then it must be them. Try not running the animation (and not loading the images in the first place) and see if that allows the app to be run on the iPod 3.
__________________
HEY! Was this post helpful?
If so, it would be MUCH appreciated if you'd just click on one of these apps:
MyD
Take 1 minute to set up your MyD and you'll always be able to prove you own your device!
Membrik
Test your memory by sliding tiles to match chains of increasing difficulty.
Is 1.9MB the size of the compressed .png files, or the uncompressed size after loading? It's the uncompressed size that matters here. I think you're talking about the compressed size since you mentioned empty space.
By empty space I'm referring to the transparent areas in the images. I'm quiet sure the images aren't compressed to begin with although it does seem like 1.9Mb for 90 images does seem incredibly low however I'm no expert on the topic. I tried reducing the amount or memory usage by putting the subview in a whole separate view so it wouldn't load when the app loads. I realise tha.t the majority of the market do not own an iPhone 4 so this is a fairly pressing issue.
Regardless of size and count of the images, you don't need to have them all loaded at the same time as you won't be showing them at the same time. Check the sample project I posted and see how they dynamically load the next image as it becomes needed.
If you are using very large images (in terms of resolution) but are only showing them to 'fit to screen' (screen resolution) consider doing some preprocessing and make smaller resolution versions to use instead of the large ones, you'll save further on memory and computing time.
By empty space I'm referring to the transparent areas in the images. I'm quiet sure the images aren't compressed to begin with although it does seem like 1.9Mb for 90 images does seem incredibly low however I'm no expert on the topic. I tried reducing the amount or memory usage by putting the subview in a whole separate view so it wouldn't load when the app loads. I realise tha.t the majority of the market do not own an iPhone 4 so this is a fairly pressing issue.
Thank you for your prompt responses
With uncompressed images (which is what you have when you load them), the fact that they are mostly empty does not matter. It still takes up the full memory to separately specify each pixel. I can't imagine how you are getting that 1.9Mb figure other than by looking at the amount of memory they take up in your app's binary image. So I guess you are reporting the irrelevant compressed size. I second baja_yu's suggestion. Find a way to have only the few images in memory that you need at once, and pre-reduce them to the resolution that is comparable to the iPod screen.
With uncompressed images (which is what you have when you load them), the fact that they are mostly empty does not matter. It still takes up the full memory to separately specify each pixel. I can't imagine how you are getting that 1.9Mb figure other than by looking at the amount of memory they take up in your app's binary image. So I guess you are reporting the irrelevant compressed size. I second baja_yu's suggestion. Find a way to have only the few images in memory that you need at once, and pre-reduce them to the resolution that is comparable to the iPod screen.
Thanks. Also thankyou baja_yu's, I'll be sure to check out the sample project. Thanks again.