ios 如何解决较早启动但现在“因内存压力而终止”的应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19061243/
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
How can I address an app that started earlier, but is "Terminated due to Memory Pressure" now?
提问by Christos Hayward
I am working on an iOS app in Xcode. Earlier I got it to start and run, up to a limited level of functionality. Then there were compilation failures claiming untouched boilerplate generated code had syntax errors. Copying the source code into a new project gets a different problem.
我正在 Xcode 中开发 iOS 应用程序。早些时候我让它启动并运行,直到功能有限。然后是编译失败,声称未触及的样板生成的代码有语法错误。将源代码复制到新项目中会遇到不同的问题。
Right now, I can compile and start running, but it states before even the launch image shows up that the application was closed due to memory pressure. The total visual assets is around 272M, which could be optimized some without hurting graphical richness, and is so far the only area of the program expected to be large. (The assets may or may not be kept in memory; for instance every current loading image is populated and my code never accesses any loading image programmatically.) And it crashes before the loading image has itself loaded.
现在,我可以编译并开始运行,但它甚至在启动图像显示之前就指出应用程序由于内存压力而关闭。总视觉资产约为 272M,可以在不损害图形丰富性的情况下进行一些优化,并且是迄今为止该程序唯一预计较大的区域。(资产可能会或可能不会保存在内存中;例如,每个当前加载图像都被填充,我的代码从不以编程方式访问任何加载图像。)并且它在加载图像自身加载之前崩溃。
How can I address this memory issue? I may be able to slim down the way images are handled, but I suspect there is another root cause. Or is this excessive memory consumption?
我该如何解决这个内存问题?我也许可以精简图像的处理方式,但我怀疑还有另一个根本原因。或者这是过度的内存消耗?
Thanks,
谢谢,
采纳答案by bneely
Review the Performance Tuningsection of Apple's iOS Programming documentation. Use Apple's Instrumentsapplication to determine how, when, and how much memory your app is using.
查看Apple 的 iOS 编程文档的性能调优部分。使用 Apple 的Instruments应用程序来确定您的应用程序使用的内存方式、时间和使用量。
One approach you should consider is to disconnect the graphics resources from your application, and add them back one-by-one once you feel they meet the requirements and limitations of iOS.
您应该考虑的一种方法是将图形资源与您的应用程序断开连接,一旦您觉得它们满足 iOS 的要求和限制,就将它们一个一个地添加回来。
Now, this part of my answer is opinion: it sounds like your app is a high risk for being rejected from the App Store, in case that is your intended destination for this app.
现在,我的这部分回答是意见:听起来您的应用被 App Store 拒绝的风险很高,以防这是您希望使用此应用的目的地。