Releasing Autoreleasepool crashes on iOS 4.0 (and on 4.1 as well..)

I'm wondering what could cause this. I have several methods in my code that i call using performSelectorInBackground. Within each of these methods i have an Autoreleasepool that is being alloced/initialized at the beginning and released at the end of the method.

this perfectly works on iOS 3.1.3 / 3.2 / 4.2 / 4.2.1 but it fataly crashes on iOS 4.0 with a EXC_BAD_ACCESS Exception that happens after calling [myPool release].

After I noticed this strange behaviour I was thinking about rewriting portions of my code and to make my app "less parallel" in case that the client os is 4.0.

After I did that, the next point where the app crashed was within the ReachabilityCallback-Method from Apples Reachability "Framework".

well, now I'm not quite sure what to do.

The things i do within my threaded methods is pretty simple xml parsing (no cocoa calls or stuff that would affect the UI). After each method finishes it posts a notification which the coordinating-thread listens to and once all the parallelized methods have finished, the coordinating thread calls viewcontrollers etc...

I have absolutely no clue what could cause this weird behaviour. Especially because Apples Code fails as well.

any help is greatly appreciated!

thanks, sam

-------------Problems Reply------------

The best way to detect zombies is:

  1. in the Groups and Files section, expand the Executables section and right click on your app name and choose Get Info
  2. select the Arguments tab on the top and then add a new entry in the Variables to be set in the environment section. Name the new variable to NSZombieEnabled and set its value to YES.

After this you will have information in console on which released objects you make calls.

Seem's like i've solved the Issue. The Problem was, that (as many of you suggested) I've overreleased an NSURL Object within a Method which calls [NSString stringWithContentsOfURL:urlRequest encoding:NSUTF8StringEncoding error:&error];

I assume that stringWithContentsOfURL autoreleases the NSURL object that i pass as a parameter.

after removing the release on urlRequest the issue dissapeared. Still i think that it's very strange that different iOS Versions behave differently on that matter.

the whole method looked like this:


NSString *data = nil;

NSError *error = nil;

data = [NSString stringWithContentsOfURL:urlRequest encoding:NSUTF8StringEncoding error:&error];

//[urlRequest release]; //Crashes on iOS 4.0 / 4.1 later when autoreleasepool is being released.

return data;


Sounds like an autoreleased object created in the scope of that autorelease pool is being released somewhere it shouldn't be. Not sure why the behaviour differs with the version of the SDK; there must be an implementation difference somewhere that's causing the issue. Have you built the code using "Build and Analyze"? Does it suggest anything might be over-released?

I've noticed some strange behavior with performSelectorInBackground also. I might be completely wrong on this, but in my case I've used:

[NSThread detachNewThreadSelector:@selector(blah) toTarget:self withObject:nil];

with better results. If, when you're in that method, you need to access the main thread (to update the UI for example), you can just:

[self performSelectorOnMainThread:@selector(blah2) withObject:nil waitUntilDone:false];

Category:iphone Views:0 Time:2010-12-17

Related post

  • UIScrollView EXC_BAD_ACCESS crash in iOS SDK 2010-09-10

    I have an iPhone SDK application that has several views that appear and disappear as the user creates content. After using the application on a device for a while, I get the following crash: Program received signal: “EXC_BAD_ACCESS”. (gdb) backtrace

  • UIImagePickerController crash on iOS 5 2011-10-18

    UIImagePickerController *ii_picker= [[UIImagePickerController alloc] init]; ii_picker.delegate=self; ii_picker.sourceType=UIImagePickerControllerSourceTypeCamera; add_photo=NO; [self presentModalViewController:ii_picker animated:YES]; [ii_picker rele

  • dismissModalViewControllerAnimated: (and dismissViewControllerAnimated) crashing in iOS 5 2011-10-19

    I can't find any logical explanation, but the fact remains that, in iOS 5 (xCode 4.2), if I presentModalView:* animated:YES, I can call dismissModalViewAnimated:* fine, but if I call presentModalView:* animated:NO, then calling the dismiss method cra

  • Object dealloc only crashes in iOS 4.3 2011-12-26

    I'm trying to figure out why pushing a viewController in my tableView using didSelectRowAtIndexPath would cause a crash in iOS 4.3, but in iOS 5.0+, it works fine. It crashes right when I call: self.customViewController = [[[CustomViewController allo

  • HTTP live streaming crashing on iOS 4.2, doesn't crash on 4.3 2011-03-28

    We have a HTTP live streaming app for ipad. There are a couple of streams we have which work fine on any OS. However, one of the streams just crashes on iOS 4.2 and on iOS 4.3, although I do not get a crash, the stream doesn't play. I get a playback

  • Include external projects when releasing an open source iOS app + static lib? 2011-04-07

    I'm planning on releasing an open-source iOS static lib and sample app that depends on a number of third-party projects (OpenSSL, SQLCipher, FMDB, CHDataStructures and GHUnit). Currently, I have all of the component projects building from source in a

  • mkmapview crashing in IOS 4.2 2011-05-09

    This is karthik. I am getting this following error when i run my application. When my application trying to find the user location its crashing. Actually in IOS 4.0 and 4.1 its working fine. Only in 4.2 its crashing. Can you help me? CoreAnimation: i

  • Debugging app crashes with iOS Simulator & XCode 4 halts in main() function, not crash source 2011-11-03

    Possible Duplicate: Xcode 4.2 showing the wrong line of code on error Xcode 4's debugger doesn't seem to halt execution anywhere near the causes of crashes in iOS Simulator. Say I introduce a bug in my code, perhaps an array out of bounds error like

  • this app was developed and works fine under ios 5.0, but crashes under ios 4.3 2011-12-06

    I developed an iPhone app under iOS 5.0, and it works fine. But when it comes to iOS 4.3(Base SDK = latest iOS 5.0, compiler = Apple LLVM 3.0, Deployment Target = iOS 4.3), it crashes after launching. The output around crash point looks like: 2011-12

  • Using presentModalViewController with UIImagePickerController causing Crash on iOS 5 2012-01-26

    Using presentModalViewController with UIImagePickerController causing Crash on iOS 5 (its running fine on version<5), i am trying to get all the albums on the device, using 'UIImagePickerControllerSourceTypeSavedPhotosAlbum' is only getting the Ca

  • UIWebView release causes crash 2012-03-19

    I have a UIViewController subclass that has a UIWebView. It adds that web view as it's view's subviews and in dealloc releases it. Here's the relevant code: #import "MediaVC.h" @implementation MediaVC @synthesize file, repository, server, delegate; -

  • Calling release method crashes iOS app 2011-09-07

    I have subclassed UIView as a Toolbar and add all kinds of buttons and other views to the class. Now, in my ViewController header I have this: @interface GridViewController : UIViewController <UIWebViewDelegate, UIScrollViewDelegate> { Toolbar

  • Just released to AppStore app crashing on iOS 3.0 incomprehensive archive 2011-12-21

    Now I'm testing app on this phone and all just fine. What the problem? on iOS 4.3 and 5.0 works fine I'm using SDK iOS 5 (valid architectures set to armv6 and armv7) EDIT this iOs device is jail broken. Can it be source of the problem? EDIT 2 I've ge

  • Out-Of-Memory crash on iOS, but memory consumption is at 20MB 2015-01-26

    I am experiencing out-of-memory crashed with my app on iOS on both iPhone 6 and 5s. I am sure that memory is the problem, because I receive memory warnings and also because of the crash log. In the app I do video processing and process around 400 ima

  • can someone please explain why this keeps crashing on iOS 4.2? 2010-11-04

    The code worked in iOS 3.2 and in 4.2 it keeps crashing. Here's the line that it crashes on. NSArray* address = [NSArray arrayWithArray:[[[access.filteredResults objectAtIndex:[indexPath row]] addressArray] objectAtIndex:0]]; 2010-11-04 12:20:03.060

  • iOS App Crashing on iOS 4.2 but not 4.0, simulator not showing logs 2010-11-30

    Using XCode 3.2.5 I can run my application on iOS Simulator using the 4.2 SDK. However, it crashes on the following function, more specifically, the presentModalViewController call: - (void)login { //check to see if they logged in correctly here /*UI

  • autoreleasing NSString in class method causing app crash in iOS 2011-07-28

    The error I receive is as follows: int main(int argc, char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); //breakpoint that says Thread 1: Program Received Signal: "EXC_BAD

  • Crash on iOS device when dereferencing a pointer returned by NSCoder's decodeBytesForKey 2011-10-11

    I've found an unusual crasher with NSCoder when using the Apple LLVM Compiler 3.0 and compiled with -O3. It only crashes on devices. I've tested an iPhone 4 running iOS 5, an iPad 2 running iOS 5 and an iPad 1 running iOS 4. All crash identically. He

  • apps works fine in iOS 4.3 but crashing in iOS 5 2011-10-18

    My apps start crashing after upgrading to iOS 5 with Xcode 4.2. Otherwise the same source is validated working in iOS 4.3. I am quite clueless about what might have occurred since the backtrace did not reveal much info. Here is what I can say about t

Copyright (C), All Rights Reserved.

processed in 0.118 (s). 11 q(s)