问题描述
打开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
:
如果在AppStore上发布,我的猜测是您不会通过审核.
If distributing on the AppStore, my guess is that you would not pass the review.
这篇关于是否应为已发布的应用关闭NSZombieEnabled?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!