An Objective-C message was sent to a deallocated object (zombie) at address: 0x75d52a0
Asked Answered
M

2

6

I am relatively new to iOS development so appreciate your help in finding out the root cause for the error that I encountered.

I tried to debug the error using Instruments (i.e. Allocations-Zombie Profiler) but I could not make sense of the call stacks that were presented.

This is how the user interfaces are linked: TabBarController -> NavigationController -> TopPlacesTableViewController -> RecentPhotosTableViewController -> PhotoViewController

The error occurs when I click on the Back button in the last view (i.e. that of the PhotoViewController). This action is supposed to show the previous RecentPhotosTableViewController but instead an unknown deallocated object was accessed, sometime in between the events of viewWillAppear and ViewDidAppear.

Additionally, I have a GenericTableViewController which is the parent of TopPlacesTableViewController and RecentPhotosTableViewController. The children set a NSMutableArray property in the parent which is the data that gets loaded in the children's views.

I am currently using iOS6 and XCode4.5.

[Update: In the Console, this line was shown - "[UIView _forgetDependentConstraint:]: message sent to deallocated instance xxx"].

Misreckon answered 6/12, 2012 at 7:54 Comment(2)
Are you compiling with ARC, or no?Songwriter
Yes I am. I just replied to Anoop Vaidya how I confirmed ARC is switched on.Misreckon
D
0

I feel you are not using ARC, and you are not retaining of passing your previous object. In the meantime the previous object is released and then you accessing it.

Either you can refactor your code to use ARC or put retain or autorelease.

Draughtsman answered 6/12, 2012 at 8:11 Comment(4)
Thanks for the prompt answer! I just checked the setting at "Your Target -> Build Settings -> Apple LLVM Compiler - Language -> Objective-C Automatic Reference Counting" and confirmed ARC is switched on. Is there anyway I can pinpoint exactly which object was released and accessed after deallocation?Misreckon
That is very difficult to find, you have to do breakpoint and and step over each and every line...a big task. Or one thing you can do is, as you are sure you are using ARC so you yourself can not do [... release]. So What you can do is make every object strong, and then check.Draughtsman
The strangest thing happened. After deleting the PhotoViewController and dragging a new one onto the storyboard, the error did not happen again.Misreckon
I am guessing the error occurred previously due to bugs in the new feature Autolayout (i.e. compiler created some NSLayoutConstraint objects but due to some unknown reason the objects were released more times than they should). By deletion and recreation, this forces Xcode to rebuild the constraints. I am assuming this because of the error message that I got from the Console (i.e. UIView _forgetDependentConstraint) but I cannot be absolutely sure. Thanks to all for your advice anyway!Misreckon
B
-1

Go to Product > edit scheme >Diagnostics tap then check on enable Zombie objects

make a break point and go step by step to know which object is deallocated, it perhaps the pointer to your object has been removed then the OS has deallocated your object.

Bamberg answered 6/12, 2012 at 8:59 Comment(1)
I have enabled Zombie objects but the call stack is not useful. The only understandable line of Objective C's code is triggered from the AppDelegate's main method (i.e. @autoreleasepool {return UIApplicationMain(argc, argv, nil, NSStringFromClass([PhotosAppDelegate class]));}).Misreckon

© 2022 - 2024 — McMap. All rights reserved.