为什么我的 iPhone 应用程序在收到内存警告时会崩溃?
这对我来说有点神秘。我的应用程序不使用太多内存,但如果我将其放在后台并运行尽可能多的内存密集型应用程序,当我尝试唤醒它时,有时我的应用程序会崩溃。
我查看了崩溃日志,这就是我所看到的:
0 libobjc.A.dylib 0x000027da objc_msgSend + 18
1 UIKit 0x0008cab4 -[UIViewController unloadViewForced:] + 132
2 UIKit 0x0008ca22 -[UIViewController unloadViewIfReloadable] + 10
3 UIKit 0x0008c9f2 -[UIViewController purgeMemoryForReason:] + 34
4 UIKit 0x0008c896 -[UIViewController didReceiveMemoryWarning] + 10
5 My Application 0x00023340 -[MailboxViewController didReceiveMemoryWarning] (MailboxViewController.m:359)
6 UIKit 0x0008c880 -[UIViewController _didReceiveMemoryWarning:] + 8
如您所见,我的视图控制器 MailboxViewController
收到一条 didReceiveMemoryWarning
消息。由于该视图没有任何可以真正释放的内存,因此我只需调用 [super didReceiveMemoryWarning]
。
奇怪的是,我没有看到对视图控制器的 viewDidUnload
的调用。它似乎在到达那里之前就因“EXC_BAD_ACCESS (SIGSEGV)”而崩溃。
这是怎么回事?我该如何解决?
This is sort of a mystery to me. My application does not use very much memory but if I put it in the background and run as many memory-intensive applications as I can, occasionally my application will crash when I try to wake it up.
I've looked at the crash log and this is what I see:
0 libobjc.A.dylib 0x000027da objc_msgSend + 18
1 UIKit 0x0008cab4 -[UIViewController unloadViewForced:] + 132
2 UIKit 0x0008ca22 -[UIViewController unloadViewIfReloadable] + 10
3 UIKit 0x0008c9f2 -[UIViewController purgeMemoryForReason:] + 34
4 UIKit 0x0008c896 -[UIViewController didReceiveMemoryWarning] + 10
5 My Application 0x00023340 -[MailboxViewController didReceiveMemoryWarning] (MailboxViewController.m:359)
6 UIKit 0x0008c880 -[UIViewController _didReceiveMemoryWarning:] + 8
As you can I see, my view controller MailboxViewController
gets a didReceiveMemoryWarning
message. Since that view doesn't have anything memory it can free really, I simply make a call to [super didReceiveMemoryWarning]
.
The strange thing is that I don't see a call to my view controller's viewDidUnload
. It seems to crash with a "EXC_BAD_ACCESS (SIGSEGV)" before it even gets there.
What is going on and how can I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜它在你的控制器卸载其视图时崩溃了,所以你的 viewDidUnload 永远不会被调用。你的观点只是简单的观点还是复杂的观点?我的猜测是,这可能与您的观点有关。
I guess it crashed at the time your controller unloading its view, so your viewDidUnload never get called. Is your view just some plain view or complex view? My guess is that it might have something to do with your view.
尝试在启用“僵尸”的情况下进行调试——看起来好像有一条消息被发送到一个已释放的对象。
Try debugging with Zombies enabled--it looks like a message is being sent to a deallocated object.