I have Xcode 4.3.1, iOS 5.1, and have ARC
turned on for building my app.
Now the app runs fine in debug build, but crash on release build. What could be the possible reason for the difference? I purely rely on ARC
for the resource management. I looked at the crash log, it's indicating that the memory that was referencing was released already. What'll be the common pitfalls that could cause the problem on retail build, when using ARC
?
The following is what I got from crash log
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x6f636552
Crashed Thread: 0
EDIT
The app's deployment target is iOS 5.0. I do use internet connections, the current crash happens on the time when "rendering" the data returned from web service in order to show on a UITableViewController
. The whole app is using ARC
, except a few source files from 3rd party for which I have ARC
turned off.
Whenever this happens to me it seems to be because release builds are more aggressive about clearing up weak references. If you mistakenly assign something to a weak property (for example, if you're adding subviews that you will also hold weak references to) before you have any strong reference to it, this can work on debug and fail on release. For example (pseudocode)
@property (weak) UILabel * label;
...
self.label = [[UILabel alloc] init];
[self.view addSubview:self.label];
...
self.label.text = @"hello";
I've seen this cause bad access crashes on release builds and go unnoticed on debug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With