Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 07-07-2009, 02:23 AM   #1 (permalink)
Latest app on AppStore
 
mgales's Avatar
 
Join Date: Jun 2009
Location: Basingstoke, Hampshire. UK
Posts: 119
Unhappy App Crashing at random!

I am writing my first test app, and am having a few problems with it.

The app consists of a TabBar, currently with only 1 Tab, and a TableView. The TableView pushes new views into place when items are selected.

On the detail view there is a button to push a map view. This uses the MapView control.

The app works as expected, but will crash (exit) at random times when switching back and forth between the TableViews.

The app only seems to crash when on an actual device, it seems to work fine in the Simulator.

I have ran the app through Instruments using the Leaks option, and have fixed the couple of leaks that were in my code (I wasn't releasing things properly), but I still have the intermittent crash problem.

I have been moving through the TableView quite quickly, and was wondering if it is just me being impatient.

If anyone has any additional ways to try and solve this problem, the help would be appriciated.
mgales is offline   Reply With Quote
Old 07-07-2009, 03:01 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by mgales View Post

If anyone has any additional ways to try and solve this problem, the help would be appriciated.
Is there any message in the console when the app crashes?

Search for NSZombies and the clang static analyzer. They're both tools that can help you find bugs in your code. It sounds like you may be releasing something *too* much now.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 07-07-2009, 03:10 AM   #3 (permalink)
Latest app on AppStore
 
mgales's Avatar
 
Join Date: Jun 2009
Location: Basingstoke, Hampshire. UK
Posts: 119
Default

Quote:
Originally Posted by smasher View Post
Is there any message in the console when the app crashes?

Search for NSZombies and the clang static analyzer. They're both tools that can help you find bugs in your code. It sounds like you may be releasing something *too* much now.
Thanks for your reply. I have no message in the console as the app doesn't crash in the simulator.

I will look for the tools you have suggested and give those a try. Are these tools a part of the SDK or are they downloaded from somewhere else? If they are additional downloads, would you be able to supply a link to where they can be got from?

Thanks,

Last edited by mgales; 07-07-2009 at 04:01 AM. Reason: Clarification of reply
mgales is offline   Reply With Quote
Old 07-07-2009, 12:18 PM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by mgales View Post
Thanks for your reply. I have no message in the console as the app doesn't crash in the simulator.

I will look for the tools you have suggested and give those a try. Are these tools a part of the SDK or are they downloaded from somewhere else? If they are additional downloads, would you be able to supply a link to where they can be got from?

Thanks,
You should still be able to see messages in the console, if you're running your app in the device directly from XCode.

NSZombies:
CocoaDev: NSZombieEnabled

Clang:
Clang Static Analyzer
__________________

Free Games!
smasher is offline   Reply With Quote
Old 07-07-2009, 12:31 PM   #5 (permalink)
Latest app on AppStore
 
mgales's Avatar
 
Join Date: Jun 2009
Location: Basingstoke, Hampshire. UK
Posts: 119
Default

Quote:
Originally Posted by smasher View Post
You should still be able to see messages in the console, if you're running your app in the device directly from XCode.

NSZombies:
CocoaDev: NSZombieEnabled

Clang:
Clang Static Analyzer
Thanks for that.

I have enabled NSZombie, and this is the error I get: -

-[MapViewController respondsToSelector:]: message sent to deallocated instance 0x10bc300

This occurs when I click the Back button in my Navigation Bar!

The view it is moving from contains a MapView!

I have narrowed the problem to the following: -

- (void)mapView {
MapViewController *mvController = [[MapViewController alloc] initWithNibName:@"MapView" bundle:[NSBundle mainBundle]];

[mvController setItemLocation:[NSString stringWithFormat:@"%@ %@", [details objectForKey:@"Latitude"], [details objectForKey:@"Longitude"]]];

[self.navigationController pushViewController:mvController animated:YES];

//[mvController release];
}

If I uncomment the [mvController release]; line the app crashed.... Shouldn't mvController be released?

The app works without this line, and I cannot find any leaks!

Thanks

Last edited by mgales; 07-07-2009 at 01:09 PM.
mgales is offline   Reply With Quote
Old 01-12-2010, 05:30 AM   #6 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 3
Default Same problem

Quote:
Originally Posted by mgales View Post
Thanks for that.

I have enabled NSZombie, and this is the error I get: -

-[MapViewController respondsToSelector:]: message sent to deallocated instance 0x10bc300

This occurs when I click the Back button in my Navigation Bar!

The view it is moving from contains a MapView!

I have narrowed the problem to the following: -

- (void)mapView {
MapViewController *mvController = [[MapViewController alloc] initWithNibName:@"MapView" bundle:[NSBundle mainBundle]];

[mvController setItemLocation:[NSString stringWithFormat:@"%@ %@", [details objectForKey:@"Latitude"], [details objectForKey:@"Longitude"]]];

[self.navigationController pushViewController:mvController animated:YES];

//[mvController release];
}

If I uncomment the [mvController release]; line the app crashed.... Shouldn't mvController be released?

The app works without this line, and I cannot find any leaks!

Thanks
Did you ever find a solution? I'm having the exact same problem.
shomarim is offline   Reply With Quote
Old 01-12-2010, 07:37 AM   #7 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 3
Default Found the solution

I found the solution:
Have You Found A Bug In MapKit? I Did. - JakeBehrens.com

Basically, set the MKMapView delegate to nil in dealloc.
mapView.delegate = nil;

I found that I also had to set
mapView.showsUserLocation = NO;
[mapView removeAnnotations:mapView.annotations];

If you're using location manager and its updating, set its delegate to nil in dealloc.
shomarim is offline   Reply With Quote
Old 03-18-2010, 08:23 PM   #8 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 22
Default mapView.showsUserLocation = YES;

I'm using CLLocationManager to get my current location.
Everything works fine with the fix described in this post.

But when I set mapView.showsUserLocation = YES; I get the same bad access exception. I have set it back to NO in dealloc but that doesn't help.

Is there a conflict between Location Manager and showsUserLocation? How can I use both without it crashing?
Peeks is offline   Reply With Quote
Old 03-19-2010, 06:07 AM   #9 (permalink)
Mobile and Web solutions
 
hello24's Avatar
 
Join Date: May 2009
Location: London, UK
Posts: 72
Send a message via Skype™ to hello24
Default

This looks like a over-released local variable in one of the views. Try using NSZombie and you'll get a meaningful message in the console.
hello24 is offline   Reply With Quote
Old 04-05-2010, 08:56 PM   #10 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 22
Default

Quote:
Originally Posted by hello24 View Post
This looks like a over-released local variable in one of the views. Try using NSZombie and you'll get a meaningful message in the console.
I got this Message

-[MKMapView userLocationViewAccuracyDidUpdate:]: message sent to deallocated instance 0x36f5fd0

The crash seems to occur when both the mapview.userlocation and my LocationManager update their view Accuracy.
Peeks is offline   Reply With Quote
Old 04-06-2010, 01:47 AM   #11 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Do you set a delegate for MKMapview? You should set the delegate property back to nil when you're done with it, otherwise it will keep calling methods on the delegate object even after the delegate object is destroyed.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 05-14-2010, 03:35 PM   #12 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 20
Default

Quote:
Originally Posted by shomarim View Post
I found the solution:
Have You Found A Bug In MapKit? I Did. - JakeBehrens.com

Basically, set the MKMapView delegate to nil in dealloc.
mapView.delegate = nil;

I found that I also had to set
mapView.showsUserLocation = NO;
[mapView removeAnnotations:mapView.annotations];

If you're using location manager and its updating, set its delegate to nil in dealloc.

Thanks a lot. You saved my day!
__________________
droolJunkie
vibhorgoyal is offline   Reply With Quote
Old 05-19-2010, 08:29 PM   #13 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 6
Default

Quote:
Originally Posted by smasher View Post
Do you set a delegate for MKMapview? You should set the delegate property back to nil when you're done with it, otherwise it will keep calling methods on the delegate object even after the delegate object is destroyed.
That's exactly what's happening. Yesterday I had a VERY strange problem where a few seconds after backing out of a nav controller view, I'd crash with a call to a deallocated object.

After a lot of fussing around about NavController mishandling my view controllers, I realized that the deallocated object WAS the viewController I'd just popped. It was set as the delegate for a CLLocationManager object that was trying its darndest to report a new location.

Just telling it to stopUpdatingLocation in the controller's -(void)dealloc{ } was enough to stop the problem.
ratbastid is offline   Reply With Quote
Old 06-02-2010, 12:19 AM   #14 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 3
Default

Quote:
Originally Posted by shomarim View Post
I found the solution:
Have You Found A Bug In MapKit? I Did. - JakeBehrens.com

Basically, set the MKMapView delegate to nil in dealloc.
mapView.delegate = nil;

I found that I also had to set
mapView.showsUserLocation = NO;
[mapView removeAnnotations:mapView.annotations];

If you're using location manager and its updating, set its delegate to nil in dealloc.
This really help alot!! Thanks!
hawshy is offline   Reply With Quote
Old 06-08-2010, 08:21 AM   #15 (permalink)
Registered Member
 
Join Date: Feb 2010
Location: Italy
Posts: 16
Send a message via AIM to iFabG
Default

Quote:
Originally Posted by hawshy View Post
This really help alot!! Thanks!
Just to give you my little experience: I had the same problem inside the the same navigation logic and had an autorelease in addNotation that gave me random errors.

Once deleted (and put in the dealloc) I fixed it.


Fabrizio
iFabG is offline   Reply With Quote
Old 08-23-2010, 03:56 AM   #16 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 1
Default Setting MKMapView delegate to nil worked

Quote:
Originally Posted by shomarim View Post
I found the solution:
Have You Found A Bug In MapKit? I Did. - JakeBehrens.com

Basically, set the MKMapView delegate to nil in dealloc.
mapView.delegate = nil;

I found that I also had to set
mapView.showsUserLocation = NO;
[mapView removeAnnotations:mapView.annotations];

If you're using location manager and its updating, set its delegate to nil in dealloc.
shomarim: Thanks for the link and suggestion. I was having the exact problem and setting the delegate to nil worked perfectly. I also followed your other suggestions, just in case. The problem was only occurring when the user (device or simulator) pressed the back button too fast, before the view fully loaded. Otherwise, I never experienced the issue. Thanks again!
gherman999 is offline   Reply With Quote
Old 09-23-2010, 04:52 PM   #17 (permalink)
I will be a billionaire.
 
IphoneSdk's Avatar
 
Join Date: Sep 2009
Location: Scarborough, United Kingdom
Age: 16
Posts: 1,292
Default

I never realised that iPhone SDK was related to Nike shoes, you learn something new everyday!
__________________
iOS Apps | Website | Twitter | Facebook
IphoneSdk is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 246
13 members and 233 guests
2WeeksToGo, ADY, BrianSlick, Dani77, Dattee, headkaze, kapps11, mer10, mgon987, sneaky, timle8n1, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,879
Threads: 89,228
Posts: 380,744
Top Poster: BrianSlick (7,129)
Welcome to our newest member, mgon987
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:45 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0