UIViewController purgeMemoryForReason: Crashing on iOS 5

后端 未结 2 646
梦如初夏
梦如初夏 2020-12-28 18:03

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

2条回答
  •  遥遥无期
    2020-12-28 18:14

    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.

    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.

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

提交回复
热议问题