简体   繁体   English

应用程序在iPad 2上工作正常,在iPad 3上崩溃,内存警告低

[英]app works fine on iPad 2, crashes on iPad 3, with low memory warning

as the title says, I have an app which works on iPad 2, but crashes on iPad 3. when running it the console gives me a low memory warning message. 正如标题所说,我有一个适用于iPad 2的应用程序,但在iPad 3上崩溃。在运行时,控制台给我一个低内存警告消息。 When the crash happens I symbolicate it, but there's really nothing that I can relate to the code, like it shows 当崩溃发生时我会对它进行符号化,但实际上并没有任何与代码相关的内容,就像它所显示的那样

   process name, UUID, rpages, recent_max, [reason] (state)

and under those column headers just hexadecimal stuff, nothing showing method calls or lines in the project. 并且在那些列标题下只是十六进制的东西,没有显示项目中的方法调用或行。

Any ideas? 有任何想法吗? am I missing some flags in the code that allows for a better crash log? 我在代码中遗漏了一些标志,以便提供更好的崩溃日志吗?

Thanks. 谢谢。

If you're getting low memory warnings and fail to release enough memory to resolve the issue, your app will almost certainly crash. 如果您收到内存不足警告并且无法释放足够的内存来解决问题,那么您的应用几乎肯定会崩溃。 The thing is, I don't think that the particulars of how or why it crashed can possibly be illuminating. 问题是,我不认为它崩溃的方式或原因的细节可能是有启发性的。 At that point, you're evaluating secondary symptoms. 那时,您正在评估继发症状。 You really need to go back and figure out why you got the low memory warning in the first place and fix that problem. 你真的需要回过头来弄清楚为什么你首先得到低内存警告并解决这个问题。

As Daniel said, you can look at Technical Note 2151 , but as it says: 正如丹尼尔所说,您可以查看技术说明2151 ,但正如它所说:

When you see a low memory crash, rather than be concerned about what part of your code was executing at the time of termination, you should investigate your memory usage patterns and your responses to low memory warnings. 当您看到内存崩溃率较低时,您应该调查内存使用模式以及对低内存警告的响应,而不是担心代码的哪一部分在终止时执行。 Memory Allocations Help lists detailed steps on how to use the Leaks Instrument to discover memory leaks, and how to use the Allocations Instrument's Mark Heap feature to avoid abandoned memory. 内存分配帮助列出了有关如何使用“泄漏仪器”发现内存泄漏的详细步骤,以及如何使用“分配仪器”的“标记堆”功能来避免丢弃内存。 Memory Usage Performance Guidelines discusses the proper ways to respond to low-memory notifications as well as many tips for using memory effectively. 内存使用性能指南讨论了响应低内存通知的正确方法以及有效使用内存的许多技巧。 It is also recommended that you check out the WWDC 2010 session, Advanced Memory Analysis with Instruments . 还建议您查看WWDC 2010会话, 使用仪器进行高级内存分析

So, a couple of thoughts: 所以,有几个想法:

  1. Have you looked for leaks? 你找过泄漏了吗? The Finding Leaks article walks you through how to use instruments to find your leaks. Finding Leaks文章将向您介绍如何使用仪器找到泄漏点。

  2. If you turned on zombies, have you turned them off? 如果你打开僵尸,你有没有把它关掉? Zombies is a great diagnostic tool, but just consumes memory. 僵尸是一个很好的诊断工具,但只是消耗内存。

  3. Have you run your code through the static analyzer ( shift + command + B or select "Analyze" on the "Product" menu)? 您是否通过静态分析器运行代码( shift + command + B或选择“Product”菜单上的“Analyze”)? Especially if using non-ARC code, this can find lots of memory issues. 特别是如果使用非ARC代码,这可能会发现很多内存问题。

  4. Have you examined your allocations for unexplained increases without offsetting decreases with the Instrument's Allocations tool. 您是否使用仪器的Allocations工具检查了无法解释的增加的分配,而没有抵消减少。 Using that, you can run the program, look at the consumption of memory on the graph and see if you see any increases that aren't offset at some point by the corresponding decreases. 使用它,您可以运行程序,查看图形上的内存消耗,看看是否看到任何增加在某个点上没有被相应的减少偏移。 And if so, highlight those increases in the graph: 如果是这样,请突出显示图表中的增量:

    For example, when running the Allocations tool, hold down the option key and then click-and-drag with your mouse to highlight a portion of the timeline, to identify what you want to inspect. 例如,在运行“分配”工具时,按住选项键,然后使用鼠标单击并拖动以突出显示时间线的一部分,以标识要检查的内容。 You probably want to focus on one of your spikes in allocations. 您可能希望专注于分配中的一个峰值。 For example, I found a bump in my allocations and highlighted it as such (this was a ludicrously simple example where I create a huge array in viewDidLoad , but hopefully it give you the idea): 例如,我在我的分配中发现了一个突破并突出显示它(这是一个非常简单的例子,我在viewDidLoad创建了一个巨大的数组,但希望它能给你这个想法):

    分配

    Note, I find it useful to show the call tree in the lower panel, it's often useful to select "Hide System Libraries", to focus on your code (and "Invert Call Tree", too). 注意,我发现在下面板显示调用树很有用,选择“隐藏系统库”通常很有用,专注于你的代码(以及“反转调用树”)。 And if you double click on the method name in Instruments (in my example, here, it would be viewDidLoad), Instruments will then show you your code that's doing the allocation: 如果您双击Instruments中的方法名称(在我的示例中,这里是viewDidLoad),Instruments会向您显示正在进行分配的代码:

    显示代码

Low memory warnings generate a different kind of log than standard crashes. 低内存警告生成与标准崩溃不同的日志类型。 Take a look at the "Understanding Low Memory Reports" section of this article to understand what happened with your application and how you can debug it using Instruments: http://developer.apple.com/library/ios/#technotes/tn2151/_index.html 看一下本文的“了解低内存报告”部分,了解您的应用程序发生了什么,以及如何使用Instruments调试它: http//developer.apple.com/library/ios/#technotes/tn2151/ _index.html

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

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