iOS内存警告已发送到已释放的UIViewController [英] iOS memory warning sent to deallocated UIViewController

查看:356
本文介绍了iOS内存警告已发送到已释放的UIViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有奇怪的行为.我的应用程序正在使用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:

[ANavigationController retain]:发送到已释放实例的消息.

[ANavigationController retain]: message sent to deallocated instance.

在调试时,我已经打印了推入控制器的地址并释放了一个地址:

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

  1. 第一次推送-推送的控制器地址为 0xDA724F0 .
  2. 如果我回过头来模拟内存警告-一切正常.
  3. 第二次推送-调用了地址为 0xDA724F0 的控制器的–dealloc方法.
  4. 新推送的控制器地址为 0xFA720F0 .
  5. 返回并模拟内存警告崩溃并显示错误:
  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]:发送到已释放实例 0xDA724F0 的消息.

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

为什么释放的控制器(在步骤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:

+ [UIViewController _traverseViewControllerHierarchyWithDelayedReleaseArray:block:]

+[UIViewController _traverseViewControllerHierarchyWithDelayedReleaseArray:block:]

推荐答案

我不确定这是解决方案还是解决问题的方法,但是禁用此特定文件的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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆