views:

315

answers:

1

OK, I know this one has been beaten to death on this forum, but I'm still having the memory problem and I have tried all the techniques on the web to get around this.

I have an application that uses the UIImagePickerController to capture an image from the camera. I've tried both creating and destroying the controller for each picture, and keeping it around for the life of the app. Both are failing. The first way crashes the phone almost immediately. While the second, leaving the controller around, crashes the app after about 5 to 7 pictures.

My original app used an undocumented API to get around this issue, but Apple rejected it because of this. I really need to get my app to the store. Does anyone have code showing how they got around the issue?

I know there is a way because there are apps on the store using the camera, but I just can't seem to get it. Any help is greatly appreciated!

I can post my code here too, if needed.

+1  A: 

I had a similar problem with a monotouch application. For me the cause turned out to be memory leaking. I was using the same UIImage variable to store each successive picture. As a result, previous pictures were being leaked. Monotouch (c#) is somewhat different than objective C in that sometimes the garbage collector takes care of this sort of thing for you. But in my case, it doesn't appear to. For me the solution was explicitly calling .Dispose() on the old image before storing the new one.

My guess is your problem may be simliar. Make sure you are not orphaning any image data and that you explicitly dispose of any data you are finished with. Also, remember that there are limitations to the amount of memory available to your app. It's also possibly that you're simply trying to hold too many pictures in memory at once.

scotru