问题描述
我有奇怪的行为.我的应用程序正在使用UINavigationController
启动.如果我按下视图控制器ANavigationController
,请返回并模拟内存,警告一切正常.
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.
如果我以相同的方式推送相同的视图控制器(ANavigationController
),请返回并模拟内存警告-应用程序崩溃并显示错误:
If I push the same view controller (ANavigationController
) the same way, go back and simulate memory warning - application crashes with error:
在调试时,我已经打印了推入控制器的地址并释放了一个地址:
While debugging this I've printed addresses of pushed controller and deallocated one:
- 第一次推送-推送的控制器地址为
0xDA724F0
. - 如果我回过头来模拟内存警告-一切正常.
- 第二次推送-调用了地址为
0xDA724F0
的控制器的–dealloc
方法. - 新推送的控制器地址为
0xFA720F0
. - 返回并模拟内存警告崩溃并显示错误:
- On first push - pushed controller address is
0xDA724F0
. - If I go back and simulate memory warning - all ok.
- Second push -
–dealloc
method of controller with address0xDA724F0
called. - New pushed controller address is
0xFA720F0
. - Going back and simulating memory warning crashes with error:
为什么释放的控制器(在步骤4中)完全收到内存警告消息?
Why deallocated controller (in step 4) gets memory warning message at all?
编辑
我正在使用ARC.
Edit
I'm using ARC.
运行Instruments测试分配并启用NSZombie后,我在预期的位置崩溃了,但是UIkit
库和负责的Caller中报告的-1参考计数为:
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:
推荐答案
我不确定这是解决方案还是解决问题的方法,但是禁用此特定文件的ARC可以解决此问题.当然,我必须自己去管理记忆.
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.
编辑
找到了解决方案.请查看我对其他问题的回答: [UINavigationController保留]:邮件发送到已释放实例
Found a solution to this. Please see my answer to my other question: [UINavigationController retain]: message sent to deallocated instance
这篇关于iOS内存警告已发送到已释放的UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!