是否应该为已发布的应用程序关闭 NSZombieEnabled?
启用 NSZombieEnabled
后,它将针对运行时发生的 EXC_BAD_ACCESS
问题提供一些防护。
我正在双重努力以确保没有/很少内存泄漏,但我可能会过度释放,因此打开 NSZombieEnabled 有助于防止这种情况,对吗?或者打开 NSZombieEnabled 后,所有内存释放操作都会转换为无操作吗?如果是这样的话,这将是一个大问题。
With NSZombieEnabled
turned on it will provide some guard against the EXC_BAD_ACCESS
issues happening at runtime.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该将其关闭,因为打开 NSZombieEnabled 意味着您分配的对象不会被释放,因此您的应用程序将会泄漏。
http://www.cocoadev.com/index.pl?NSZombieEnabled
''NSZombieEnabled 应该不会永久保留在原处,因为默认情况下不会真正释放任何对象,从而使您的应用程序使用大量内存”
You should turn it off because having the NSZombieEnabled on means the objects you allocated are not deallocated, hence your app will be leaking.
http://www.cocoadev.com/index.pl?NSZombieEnabled
''NSZombieEnabled should not be left in place permanently, as by default no objects will ever be truly deallocated, making your application use tremendous amounts of memory''
不,您不应附带
NSZombiesEnable
。僵尸通过将已释放对象的 isa 指针强制转换为“僵尸”类来工作。除非启用NSDeallocateZombies
,否则不会释放此对象的存储空间。因此,如果启用僵尸,则可能会泄漏内存。此外,Apple 表示不要在
NSDebug.h
中启用它:如果在AppStore上分发,我的猜测是你不会通过审核。
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 unlessNSDeallocateZombies
is enabled. Therefore, if you leave zombies enabled, you may be leaking memory.In addition, Apple says not to leave it enabled in
NSDebug.h
:If distributing on the AppStore, my guess is that you would not pass the review.