When you get an EXC_BAD_ACCESS
, it often means you're trying to call a method on an object that isn't there -- probably because it's been deallocated.
About halfway down the trace, there are some memory warning calls, such as:
#12 0x30a00710 in -[UIApplication _performMemoryWarning] ()
Which makes it appear that none of your code is directly causing the crash, but rather a system notification when memory runs low.
Closer to frame #0, it appears to be attempting to clear the cache of a UIImage
object, and this appears to be the bad access.
Based on this, one guess is that you're assigning a pointer to the autoreleased return value of a convenience constructor; then the object is autoreleased, and you might think it's fine because you don't use the image directly, but the memory warning tries to access it. For example:
@interface MyClass {
UIImage* myImage;
}
// ...
- (id) init { /* the usual stuff */
myImage = [UIImage imageNamed:@"bob_the.png"];
return self;
}
In this example, even if you have a retain property set up on myImage
, you're not actually retaining the image unless you set the value via self.myImage
. So, shortly after this call, the image is released, and you've got a pointer to no man's land.
Without seeing the code, I have no way of knowing if that's what's actually going on, but it's one type of mistake that's easy to make.
These related questions give tips on similar crashes: EXC_BAD_ACCESS
debugging question 1 and question 2.
Finally, if none of that helps, I suggest finding a minimal reproduction of your problem. The hard way to do this is to copy your code, cut out half, see if the error is still there, and repeat until you get the smallest code you can find which reproduces the error. It's usually a lot easier to debug from there (and more postable as a stackoverflow question, too!) If you know the easy way, let me know.