[英]Why am I seeing all these leaks when NSZombie is enabled?
I am nearing completion on my first app and I'm suddenly seeing that the app is causing memory leaks. 我的第一个应用程序即将完成,我突然发现该应用程序导致内存泄漏。 I have found a few leaks and fixed them. 我发现了一些泄漏并修复了它们。 Now there are no leaks but to my surprise when NSZombie is enabled it is showing more than 4000 leaks which are mainly from frameworks. 现在没有泄漏,但令我惊讶的是,当NSZombie启用时,它显示超过4000个泄漏,主要来自框架。
I am confused with the exact use of NSZombie. 我对NSZombie的确切用法感到困惑。 Is it only used for finding the zombies or is it in any way useful for finding leaks? 它只用于寻找僵尸还是以任何方式找到泄漏?
Here is a screenshot that shows all the leaks which are associated with the frameworks: 这是一个屏幕截图,显示了与框架相关的所有泄漏:
I believe the command line option 'NSDeallocateZombies' defaults to NO. 我相信命令行选项'NSDeallocateZombies'默认为NO。 So zombies are never deallocated and thus appear as leaks if zombies (NSZombiesEnabled) are on. 因此僵尸永远不会被释放,因此如果僵尸(NSZombiesEnabled)打开则会出现泄漏。 Never test for leaks with zombies on. 切勿用僵尸测试泄漏。 You can turn NSDeallocateZombies to YES as well but I'm not sure how that interacts with Instruments. 您也可以将NSDeallocateZombies转为YES,但我不确定它与Instruments的交互方式。 A zombie is a special object that responds to all messages with an exception. 僵尸是一个特殊对象,它响应所有带有异常的消息。 In order to make this useful it has to live a long time (so you can catch when you try to reuse a deallocated object) but that makes it look exactly like a leak. 为了使它变得有用,它必须存活很长时间(所以你可以在尝试重用已释放的对象时捕获它),但这使它看起来完全像泄漏。
if NSZombie is enable a "release" do not free the memory. 如果NSZombie启用“释放”,则不释放内存。 NSZombie is used for test if you use a object already released 如果您使用已发布的对象,NSZombie将用于测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.