xcode iPhone 应用程序随机崩溃,没有任何错误或堆栈跟踪
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10888080/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iPhone app crashes randomly without any error or stack trace
提问by Kunal Balani
I am new here . Sorry if I this question is being repeated but I have a slightly different issue than the others.
我刚来这地方 。对不起,如果我重复这个问题,但我的问题与其他问题略有不同。
My app crashes randomly after certain amount of time interval without any error logs or stack trace. I suspect it's an memory issue . I have the following questions :
我的应用程序在一定时间间隔后随机崩溃,没有任何错误日志或堆栈跟踪。我怀疑是内存问题。我有以下问题:
1.) How to get stack trace (I have tried NSZombie enabled and NSUnacughtExcpetion handler) but didn't worked
2.) I get Memory warning frequently in my app. How do I confirm whether it's the prime suspect for the above issue? (I have used Leaks, my app crashes when it has just 4Mb usage so I am not quite sure whether memory leak is causing it my app to crash. I know certain application which take heap memory more than 4MB .)
3.) What is the upper limit for Memory leak for an application in iOS before app crashes ?
4.) Would ARC help me in this situation ?
1.) 如何获取堆栈跟踪(我尝试过启用 NSZombie 和 NSUnacughtExcpetion 处理程序)但没有奏效
2.) 我的应用程序中经常收到内存警告。我如何确认它是否是上述问题的主要嫌疑人?(我使用了 Leaks,我的应用程序在只有 4Mb 使用时崩溃,所以我不太确定内存泄漏是否导致我的应用程序崩溃。我知道某些应用程序占用的堆内存超过 4MB 。)
3.) 在应用程序崩溃之前,iOS 中应用程序的内存泄漏上限是多少?
4.) 在这种情况下 ARC 会帮助我吗?
Also, I have tried to debug issue using NSLog statements but since it crashes randomly , it would be hard for me to detect the root cause using this technique.
此外,我尝试使用 NSLog 语句调试问题,但由于它随机崩溃,我很难使用这种技术检测根本原因。
Any ideas would be or help would be really appreciated
任何想法或帮助将不胜感激
回答by Vincent Gable
My app crashes randomly after certain amount of time interval without any error logs or stack trace. I suspect it's an memory issue.
我的应用程序在一定时间间隔后随机崩溃,没有任何错误日志或堆栈跟踪。我怀疑是内存问题。
To confirm that it's a memory issue, sync your device with iTunes,and look in ~/Library/Logs/CrashReporter/MobileDevice/
for a files with LowMemory
in their name. If you see (jettisoned)
next to your app name, that confirms it was killed by iOS for using too much memory.
要确认这是内存问题,请将您的设备与 iTunes 同步,然后查找名称中~/Library/Logs/CrashReporter/MobileDevice/
包含的文件LowMemory
。如果您(jettisoned)
在应用名称旁边看到,则确认它因使用过多内存而被 iOS 杀死。
The only other way an app could exit without leaving a crash report is if it erroneously called exit()
.
应用程序可以退出而不留下崩溃报告的唯一另一种方式是如果它错误地调用了exit()
.
For more information, see "Debugging Deployed iOS Apps", and "Understanding and Analyzing iOS Application Crash Reports".
有关更多信息,请参阅“调试已部署的 iOS 应用程序”和“了解和分析 iOS 应用程序崩溃报告”。
回答by shrishaster
Not sure but reading the registers might help.
不确定,但阅读寄存器可能会有所帮助。
First go to Exceptions tab and 'Add Exception Breakpoint' using the + at the bottom left corner.
首先使用左下角的 + 转到“异常”选项卡和“添加异常断点”。
Then when the app crashes click on "0 objc_exception_throw" under Thread 1
然后当应用程序崩溃时,点击线程 1 下的“0 objc_exception_throw”
Finally in the console enter:
最后在控制台输入:
- register read (you should get a list of registers)
po $rax (normally the exception is in 'rax')
(you should see the exception output on the console)
- 寄存器读取(你应该得到一个寄存器列表)
po $rax (通常例外在 'rax' 中)
(您应该会在控制台上看到异常输出)
Hope this helps.
希望这可以帮助。
回答by Nate
That does sound like maybe the device is running low on memory and shutting you down. There's lots of threads on stackoverflow on debugging memory warnings.
这听起来确实像是设备内存不足而导致您关机。stackoverflow 上有很多关于调试内存警告的线程。
This one talks a little about what to look for when using the Instruments tool.
这篇文章讨论了使用 Instruments 工具时要查找的内容。
Here is an explanation of how to get the memory warning level, and what the codes mean.
这里解释了如何获得内存警告级别,以及代码的含义。
There is no fixed memory limit on iPhones. I've asked Apple support representatives this question, and they wouldn't give me a fixed answer (probably because the algorithm does not actually enforce any one hard limit for a 3rd-party app).
iPhone 没有固定的内存限制。我已经问过 Apple 支持代表这个问题,他们不会给我一个固定的答案(可能是因为该算法实际上并未对 3rd 方应用程序强制执行任何硬限制)。
And, yes, ARC can be a wonderful thing. In your situation, you might have to rework a lot of code to make it all ARC-compliant, but ARC is definitely a useful feature, and can produce programs with fewer memory problems, with less work by the coders (leaving you more time to fix other problems!)
而且,是的,ARC 可以是一件很棒的事情。在您的情况下,您可能需要重新编写大量代码以使其全部符合 ARC,但 ARC 绝对是一个有用的功能,并且可以生成内存问题更少的程序,编码人员的工作更少(让您有更多时间解决其他问题!)
回答by iArezki
回答by SoliQuiD
In my case i closed all other apps and it started working normally, maybe it was a memory issue
就我而言,我关闭了所有其他应用程序并开始正常工作,可能是内存问题