是否应为已发布的应用关闭NSZombieEnabled? [英] Should NSZombieEnabled be turned off for released app or not?

查看:97
本文介绍了是否应为已发布的应用关闭NSZombieEnabled?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

打开NSZombieEnabled可以为运行时发生的EXC_BAD_ACCESS问题提供一定的防护.

With NSZombieEnabled turned on it will provide some guard against the EXC_BAD_ACCESS issues happening at runtime.

我正在做双重努力,以确保没有/很少的内存泄漏,但是我可能会过分释放,因此打开NSZombieEnabled将有助于防止这种情况,对吗?还是打开NSZombieEnabled,所有内存释放操作都将转换为无操作吗?确实是一个大问题.

I am doing dual-diligence to make sure no/little memory leaks, but I might over releasing so having NSZombieEnabled turned on would help prevent that, am I right? Or with NSZombieEnabled turned on, would all memory releasing operations be translated into no-op? It'll be a big problem is that's the case.

推荐答案

否,您不应该随NSZombiesEnable一起发货.僵尸通过将释放对象的isa指针转换为僵尸"类来工作.除非启用NSDeallocateZombies,否则不会释放该对象的存储.因此,如果您启用了僵尸"功能,则可能正在泄漏内存.

No, you should not ship with NSZombiesEnable. Zombies work by casting the isa pointer of deallocated objects to a "zombie" class. The storage for this object is not freed unless NSDeallocateZombies is enabled. Therefore, if you leave zombies enabled, you may be leaking memory.

此外,苹果表示不要在NSDebug.h中保持启用状态:

In addition, Apple says not to leave it enabled in NSDebug.h:

不要依赖于代码中是否存在任何这些符号 在此软件的将来版本中.当然,不要依赖于 生产代码中此标头中的符号.

Do not depend on the existance of any of these symbols in your code in future releases of this software. Certainly, do not depend on the symbols in this header in production code.

如果在AppStore上发布,我的猜测是您不会通过审核.

If distributing on the AppStore, my guess is that you would not pass the review.

这篇关于是否应为已发布的应用关闭NSZombieEnabled?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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