该应用程序在iPad 2上正常运行,在iPad 3上崩溃,并显示内存不足警告 [英] app works fine on iPad 2, crashes on iPad 3, with low memory warning

查看:163
本文介绍了该应用程序在iPad 2上正常运行,在iPad 3上崩溃,并显示内存不足警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所述,我有一个可在iPad 2上运行的应用程序,但在iPad 3上崩溃.运行该控制台时,控制台会向我显示内存不足警告消息.当崩溃发生时,我用符号表示,但实际上没有任何我可以与代码相关的内容,就像它显示的

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. 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?

谢谢.

推荐答案

如果您收到内存不足警告,并且未能释放足够的内存来解决问题,则您的应用几乎肯定会崩溃.问题是,我认为崩溃的方式或原因的细节可能无法阐明.那时,您正在评估继发症状.您确实需要回过头来弄清楚为什么为什么出现内存不足警告,并解决该问题.

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:

当看到内存不足崩溃时,而不是担心终止时代码的哪个部分正在执行,您应该调查内存使用模式以及对内存不足警告的响应. 内存分配帮助列出了有关如何使用泄漏检测工具发现内存泄漏以及如何使用分配检测工具的标记堆功能避免遗弃内存的详细步骤. 内存使用性能指南讨论了响应低内存通知的正确方法,以及有效使用内存的许多技巧.还建议您检查WWDC 2010会话,高级内存分析仪器.

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.

所以,有几点想法:

  1. 您是否在寻找泄漏?

  1. Have you looked for leaks? The Finding Leaks article walks you through how to use instruments to find your leaks.

如果您打开了僵尸,是否将其关闭了?僵尸是一个很棒的诊断工具,但只会消耗内存.

If you turned on zombies, have you turned them off? Zombies is a great diagnostic tool, but just consumes memory.

您是否已通过静态分析器运行代码( shift + 命令 + B ,或在产品"菜单)?尤其是在使用非ARC代码的情况下,这会发现很多内存问题.

Have you run your code through the static analyzer (shift+command+B or select "Analyze" on the "Product" menu)? Especially if using non-ARC code, this can find lots of memory issues.

您是否已使用工具的Allocations工具检查了分配的无法解释的增加而没有抵消减少.使用它,您可以运行该程序,查看图表上的内存消耗,并查看是否看到某些增加没有在某个时候被相应的减少抵消.如果是这样,请在图表中突出显示这些增加:

Have you examined your allocations for unexplained increases without offsetting decreases with the Instrument's Allocations tool. 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:

例如,运行分配"工具时,按住Option键,然后用鼠标单击并拖动以突出显示时间轴的一部分,以标识要检查的内容.您可能想要关注分配中的峰值之一.例如,我在分配中发现一个障碍,并以此来突出显示它(这是一个非常简单的示例,其中我在viewDidLoad中创建了一个巨大的数组,但希望它能为您提供想法):

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):

注意,我发现在下部面板中显示调用树很有用,选择隐藏系统库"以专注于代码(以及反转调用树")通常也很有用.而且,如果您双击Instruments中的方法名称(在我的示例中,该名称为viewDidLoad),则Instruments将向您显示进行分配的代码:

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:

这篇关于该应用程序在iPad 2上正常运行,在iPad 3上崩溃,并显示内存不足警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆