UIViewController purgeMemoryForReason:在iOS 5上崩溃 [英] UIViewController purgeMemoryForReason: Crashing on iOS 5

查看:93
本文介绍了UIViewController purgeMemoryForReason:在iOS 5上崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我经常在运行iOS 5的iPad和iPad 2上的Crashlytics中经常看到这种崩溃。看起来它是由内存警告引起的,但是堆栈跟踪没有引用我的任何应用程序代码,只是iOS框架:

So I've been seeing this crash pretty frequently in Crashlytics, both on iPad and iPad 2, running iOS 5. It looks like it's caused by a memory warning, but the stack trace doesn't reference any of my application code, just iOS frameworks:

0    libobjc.A.dylib    objc_msgSend + 15
1    UIKit          -[UIViewController purgeMemoryForReason:] + 64
2    Foundation     __57-[NSNotificationCenter addObserver: selector: name: object:]_block_invoke_0 + 18
3    CoreFoundation     ___CFXNotificationPost_block_invoke_0 + 70
4    CoreFoundation     _CFXNotificationPost + 1406
5    Foundation     -[NSNotificationCenter postNotificationName: object: userInfo:] + 66
6    Foundation     -[NSNotificationCenter postNotificationName: object:] + 30
7    UIKit          -[UIApplication _performMemoryWarning] + 80
8    UIKit          -[UIApplication _receivedMemoryNotification] + 174
9    libdispatch.dylib  _dispatch_source_invoke + 516
10   libdispatch.dylib  _dispatch_queue_invoke + 50
11   libdispatch.dylib  _dispatch_main_queue_callback_4CF + 156
12   CoreFoundation     __CFRunLoopRun + 1268
13   CoreFoundation     CFRunLoopRunSpecific + 300
14   CoreFoundation     CFRunLoopRunInMode + 104
15   GraphicsServices   GSEventRunModal + 156
16   UIKit          UIApplicationMain + 1090
17   500px iOS      main.m line 12

我已经googled高低,但无法找到任何解决方案。看起来这是由于过度释放UIViewController实例引起的,但我正在使用ARC,所以我不明白这是怎么回事。

I've googled high and low but can't find any solutions to this. It looks like this is caused by over-releasing a UIViewController instance, but I'm using ARC, so I don't see how that could be the case.

I我不知道如何处理这个问题。我甚至无法分辨哪个UIViewController子类导致了这个问题。我已经尝试在模拟器和设备上重现问题,但我找不到导致它的原因。有没有人见过这样的事情或有关如何处理再现问题的建议?

I'm at a loss of how to even approach this. I can't even tell which UIViewController subclass is causing the issue. I've tried reproducing the problem in the simulator and on the device, but I can't find what causes it. Has anyone seen anything like this or have suggestions on how to approach reproducing the issue?

推荐答案

我想我已经解决了这个问题。我正在考虑它,问题不在于卸载UIViewController视图,而是发布了实际的低内存警告通知。我的代码中有几个实例,我调用 [[NSNotificationCenter defaultCenter] removeObserver:self] 。这在dealloc方法中很好,但在 viewDidUnload 方法中有两个这样的实例。

I think I've solved the issue. I was thinking about it, and the problem isn't the unloading of the UIViewController view, it's the posting of the actual low memory warning notification. There are several instances in my code where I call [[NSNotificationCenter defaultCenter] removeObserver:self]. This is fine in the dealloc method, but there were two instances of this in viewDidUnload methods.

当我在其中一个UIViewController的 didReceiveMemory 中的断点没有被击中时,我注意到了这一点。 viewDidUnload 中的代码也从其他系统通知中取消注册 self ,详细信息如这里

I noticed this when my breakpoint in didReceiveMemory of one of the UIViewController's wasn't getting hit. The code in viewDidUnload was also unregistering self from other, system notifications as well, as detailed here.

我是在我确认崩溃因新更新而停止之前,不要将此标记为已接受的答案。

I'm not going to mark this as an accepted answer until I verify that the crashes stop with the new update.

更新:我已经通过Crashlytics验证问题已得到解决!

UPDATE: I've verified with Crashlytics that the problem has been fixed!

这篇关于UIViewController purgeMemoryForReason:在iOS 5上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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