问题
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:
- On first push - pushed controller address is
0xDA724F0. - If I go back and simulate memory warning - all ok.
- Second push -
–deallocmethod of controller with address0xDA724F0called. - New pushed controller address is
0xFA720F0. - Going back and simulating memory warning crashes with error:
[ANavigationController retain]: message sent to deallocated instance0xDA724F0.
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:
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
来源:https://stackoverflow.com/questions/24868404/ios-memory-warning-sent-to-deallocated-uiviewcontroller