tags:

views:

101

answers:

1

I have briefly described the working of my application to under stand my Question.

I have an application, in which more than 1600 images are stored with in iPhone-Application-Document Directory. I have a tableView on Main Screen as follows. =>First Category =>Second Category =>Third Category

=>if user selects First category, Images are loaded in my ScrollView
Like
|--------------------Page View Controller-----------------|
| First Image | Second Image | Third Image | Fourth Image |
|--------------------Page View Controller-----------------|

After selecting Category, User can see - First Image From Page view Controller & others are already loaded in page View Control, user has to just scroll left - right to see the other images, but at a time user can see only one image.(that is the task of page view control)

Now Each Page has an Image View Placed in Scroll View (so user can zoom in out)

All this things work Perfectly,

Problem occurs in following situation.
=>After watching first category's images
=>User presses Back
=>Now user selects second category to view all images of second category are loaded in page view controll.

iPhone terminates the application in the given situation. (as it can't load all images to page view control) (each image is of at-least 4 MB approximately.)

iPhone simulator works perfectly in described situation but iPhone doesn't. iPhone terminates the application in given situation.

I think there might be memory caching problem in iPhone.

Question is how to resolve this problem?

Thanks in advance for helping me.

+1  A: 

You are having a memory problem, you need to manage your pictures better, release them from memory when not in use. For your scroll view dont load all images at once, load at most three, this is all you need, the reason i say three is because youll have something like this

PIC ActivePic Pic or ActivePic Pic - here you only need 2

You load picture on each side of the active picture so when the user scrolls clipping does not occur. When you are not in the scroll view make sure to release all the images if not ull run out of memory like you have been expiriencing. Look at the sample project PageControl here http://developer.apple.com/iphone/library/samplecode/PageControl/, here they manage t he views of the scroll view in the same fashion described above.

Daniel
@Daniel - sorry, I am changing my question a little bit.
sugar
What are the r esolutions on your pictures?
Daniel
You are still running o ut of memory you need to identify why, could be that you are not releasing the other images properly, or you are using images that are of too high of resolution, u should shrink them down to 320x480 or 480x320 if they arent that already, if they are something like 1600x1400 that will def crash your app
Daniel
Yep, Images were of large size, so it is.What i did is, something like this. mageDatafromPhoto = UIImageJPEGRepresentation([info objectForKey:@"myimge"],0.2);I downSized my image to size that "@Daniel" told.He is right.Problem is resolved.
sugar