views:

650

answers:

2

Hi,

I've developed my application using my 3G device to test with. Upon giving this to a friend to test, he's noticed that it crashes..I've had a look at the crash log, but it's not much use except for the "EXC_BAD_ACCESS" statement after a few memory warnings.

On my device, I can use the imagePicker lots, and each time a photo is taken I get a memory warning, but this doesn't cause any problems.

On my friend's device (also a 3G), after a couple of images chosen from the camera, the app crashes.

So, my question is.. I think something is being deallocated because of the memory warning - but only on my friend's device, and then after deallocation, it's trying to be used again. How can I find out what object is being called? I can't use NSZombies because this is a remote (beta) device.

Help please!

Also if anyone has any ideas why my device can pick image after image without any problem and his can't...that would be most helpful

Thanks!

EDIT: New discovery.. I'm getting this error message too: KERN_PROTECTION_FAILURE which I understand to be something to do with data access. The crash seems to happen right after I save the image got from the UIImagePicker. Any ideas?

A: 

You should have your friend come to your computer and run it with NSZombieEnabled. That's the best way to debug these issues.

Mike
Yeah, that's what I'd like to do, but it's pretty impossible. Is there no way to log anything like this?
mac_55
+1  A: 

You may be over-releasing something. If you're running Snow Leopard, run the Static Analyzer (Cmd-Shift-A) and look for memory errors.

The fact that it crashes after a memory error suggests that a UIViewController has released its view. Do you have any UIViewControllers that observe NSNotifications, or otherwise might change their IBOutlets while they are off-screen? This is a common cause of this kind of crash. Make sure you're correctly memory managing your IBOutlets. UIViewControllers should never mess with their IBOutlets (or their UI components at all) when they are off screen. Even if you don't make this mistake, if you're not implementing things as noted in the above link, you can still crash after memory warnings.

MemoryWarning was a pretty good idea, and things have improved, but Apple still hasn't quite cooked all the issues around how it plays with UIViewController. The developer still needs to be very careful.

Rob Napier
Hi. I tried Static Analyzer and no errors came up. Actually, nothing happened at all, except a 'Succeeded' message at the bottom of the window. Very odd.
mac_55
Not that odd. Just means you don't have obvious errors. Mismanaging IBOutlets won't be caught by clang, nor will notifications to released objects.
Rob Napier
From my log file I can see the following. Does this mean that the problem is occuring at [PictureView clearPage]?Exception Type: EXC_BAD_ACCESS (SIGBUS)Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000fCrashed Thread: 0Thread 0 Crashed:0 libobjc.A.dylib 0x00003ebc objc_msgSend + 201 MyApp 0x0000378a -[PictureView clearPage] (PictureView.m:79)
mac_55
Sure; look at line 79 in PictureView.m and see what pointer is being dereferenced. It's going to be the one you're sending the message to (since it's failing in objc_msgSend).
Rob Napier