Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-14-2010, 09:52 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 53
elfarez is on a distinguished road
Unhappy Memory problem???

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.

Any help or advice would be greatly appreciated.
elfarez is offline   Reply With Quote
Old 11-14-2010, 10:06 AM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

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…
baja_yu is offline   Reply With Quote
Old 11-14-2010, 10:21 AM   #3 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

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.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 11-14-2010, 10:28 AM   #4 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 53
elfarez is on a distinguished road
Default

Quote:
Originally Posted by smasher View Post
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.

Cheers.
elfarez is offline   Reply With Quote
Old 11-14-2010, 01:19 PM   #5 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

Quote:
Originally Posted by elfarez View Post
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.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 11-14-2010, 05:34 PM   #6 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 386
SoulRed12 is on a distinguished road
Default

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.

©2011 Dardom Productions | Like us on Facebook!
SoulRed12 is offline   Reply With Quote
Old 11-15-2010, 10:14 AM   #7 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 53
elfarez is on a distinguished road
Default

Quote:
Originally Posted by smasher View Post
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.

Thank you for your prompt responses
elfarez is offline   Reply With Quote
Old 11-15-2010, 12:38 PM   #8 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

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.
baja_yu is offline   Reply With Quote
Old 11-15-2010, 02:44 PM   #9 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Quote:
Originally Posted by elfarez View Post
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.
RLScott is offline   Reply With Quote
Old 11-16-2010, 10:05 AM   #10 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 53
elfarez is on a distinguished road
Default

Quote:
Originally Posted by RLScott View Post
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.
elfarez is offline   Reply With Quote
Reply

Bookmarks

Tags
memory

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 373
7 members and 366 guests
apatsufas, Kirkout, lzwasyc, MarkC, Sami Gh, SamorodovAlex, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:43 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0