How to Fix an App that Crashes in Release but n...

解决iOS app崩溃问题及优化策略
本文讨论了在iOS app开发中遇到的崩溃问题,通过调整xcode中targets的优化级别,从None到Faster,成功定位并解决了版本奔溃现象。详细解释了不同优化级别的作用与影响,为开发者提供了优化app性能的有效方法。

    今天在测试app时,发现app store上版本有奔溃现象,但是直接用xcode跑本地程序没问题。猜测release&debug版本造成的,后发现targets的 optimization level设置问题,将release版本的optimization level改为none后程序不再崩溃。

参考见: http://www.mindjuice.net/2011/11/30/how-to-fix-an-app-that-crashes-in-release-but-not-debug/

关于优化级别:GCC_OPTIMIZATION_LEVEL 描述如下
None: Do not optimize. [-O0]

With this setting, the compiler's goal is to reduce the cost of compilation and to make debugging produce the expected results.  Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the function and get exactly the results you would expect from the source code.

Fast: Optimizing compilation takes somewhat more time, and a lot more memory for a large function. [-O, -O1]

 With this setting, the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compilation time. In Apple's compiler, strict aliasing, block reordering, and inter-block scheduling are disabled by default when optimizing.

Faster: The compiler performs nearly all supported optimizations that do not involve a space-speed tradeoff. [-O2]

With this setting, the compiler does not perform loop unrolling or function inlining, or register renaming.  As compared to the 'Fast' setting, this setting increases both compilation time and the performance of the generated code.

Fastest: Turns on all optimizations specified by the 'Faster' setting and also turns on function inlining and register renaming options. This setting may result in a larger binary. [-O3]

Fastest, smallest: Optimize for size.  This setting enables all 'Faster' optimizations that do not typically increase code size.  It also performs further optimizations designed to reduce code size.

转载于:https://my.oschina.net/michael1986/blog/129607

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值