2
votes

I have strange behavior. My application being launched with UINavigationController. If I push view controller ANavigationController, go back and simulate memory warning everything works good.

If I push the same view controller (ANavigationController) the same way, go back and simulate memory warning - application crashes with error:

[ANavigationController retain]: message sent to deallocated instance.

While debugging this I've printed addresses of pushed controller and deallocated one:

  1. On first push - pushed controller address is 0xDA724F0.
  2. If I go back and simulate memory warning - all ok.
  3. Second push - –dealloc method of controller with address 0xDA724F0 called.
  4. New pushed controller address is 0xFA720F0.
  5. Going back and simulating memory warning crashes with error:

    [ANavigationController retain]: message sent to deallocated instance 0xDA724F0.

Why deallocated controller (in step 4) gets memory warning message at all?

Edit

I'm using ARC.

Edit

After running Instruments to test allocations and enabling NSZombie i got crash in the expected place, however -1 reference count reported in UIkit library and responsible Caller is:

+[UIViewController _traverseViewControllerHierarchyWithDelayedReleaseArray:block:]

1
Set the 'all exceptions' breakpoint and take a look at what's happening on the stack when the exception is thrown. Sounds like you've got a bad pointer somewhere, and now you just have to find it. It would also help to know if you're using ARC or not, though these days there's little reason not to.Caleb
What are you doing in didReceieveMemoryWarning ?CW0007007
Nothing. Just calling [super didReceieveMemoryWarning]. Also to eliminate possible issues with delegates I cleard all my class and left it in simplest state where all i do is setting background color to a view.Misha
Can you give as simple as possible example that such error throws? If you have implemented view lifecycle methods please paste them here.Szu
The problem is that when I created such example for myself in order to test simple push functionality, this error did not happen. In my project i do a lot of stuff like subclassing viewcontrollers and customising navBar so i have no idea from where to startMisha

1 Answers

0
votes

I'm not sure whether this is a solution or a workaround for a problem but disabling ARC for this specific file resolved this problem. Of course I had to go and to manage memory by myself.

Still I'll appreciate any clue for what is the problem.

EDIT

Found a solution to this. Please see my answer to my other question: [UINavigationController retain]: message sent to deallocated instance