简体   繁体   English

调试 iOS 应用程序:在 Xcode 下崩溃但在 iPhone 上继续工作

[英]Debugging iOS application: crash under Xcode but keep working on iPhone

I am trying to debug my iOS app on iPhone using Xcode.我正在尝试使用 Xcode 在 iPhone 上调试我的 iOS 应用程序。

I'm starting the app through Xcode debugger and application works fine for a couple of minutes.我正在通过 Xcode 调试器启动应用程序,应用程序可以正常工作几分钟。 Then i'm getting error message from Xcode:然后我从 Xcode 收到错误消息:

The app "myapp" on "iPhone_device" quit unexpectedly.
Message from debugger: Terminated due to signal 9

But application on iPhone keeps working like nothing happend.但是 iPhone 上的应用程序像什么也没发生一样继续工作。

Is this normal?这是正常的吗? What is the possible reasons of such Xcode behavior?这种 Xcode 行为的可能原因是什么?

UPDATE: my app is VoIP application that working in background.更新:我的应用程序是在后台工作的 VoIP 应用程序。 I've just found out that this kind of apps can be started automatically in the background after the crash.我刚刚发现这种应用程序可以在崩溃后在后台自动启动。 Could this be an issue?这可能是一个问题吗?

Your app is most likely being terminated due to low memory.您的应用很可能因内存不足而被终止。 The best thing is to look at the device console using Xcode's Organizer:最好的办法是使用 Xcode 的 Organizer 查看设备控制台:

If iOS is running out of memory and killing your app, you should see something like this:如果 iOS 内存不足并杀死了您的应用程序,您应该会看到如下内容:

The app "myapp" on "iPhone_device" quit unexpectedly.
Message from debugger: Terminated due to signal 9

You should use the Activity Monitor in Instruments to see how much memory your application is using.您应该使用 Instruments 中的活动监视器来查看您的应用程序使用了多少内存。

You can also use the Memory Monitor instrument and enable graphing of "Physical Memory Free".您还可以使用内存监视器工具并启用“物理内存可用”的图形。 If you see the graph approaching 0 before your crash you can be pretty sure it's a memory issue.如果您在崩溃前看到图表接近 0,您可以确定这是内存问题。

在此处输入图片说明

This means that your app is using lot of memory and due to this the app is killed.这意味着您的应用程序正在使用大量内存,因此应用程序被终止。 Check for memory leakages.检查内存泄漏。

I got the same error when I was trying to run an app on my iPhone 5s when I had my iPhone 6 connected.当我连接 iPhone 6 时,当我尝试在 iPhone 5s 上运行应用程序时,我遇到了同样的错误。 All I had to do was disconnect the iPhone 6 and it worked after.我所要做的就是断开 iPhone 6 的连接,然后它就可以工作了。

On iOS, an app can seem to keep running.在 iOS 上,应用程序似乎可以继续运行。 When you put an app in the background, it can be killed by iOS when the device runs out of memory.当您将应用程序置于后台时,当设备内存不足时,它可能会被 iOS 杀死。 Unlikely to happen on your Mac with the simulator.使用模拟器在 Mac 上不太可能发生。 If you go back to the app, it will be relaunched and go to the exact place where you left it.如果您返回该应用程序,它将重新启动并转到您离开它的确切位置。 User doesn't notice that it was killed in between.用户没有注意到它在两者之间被杀死。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM