Should NSZombieEnabled be turned off for released app or not?

走远了吗. 提交于 2019-12-06 03:52:27

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.

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.

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

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''

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!