什么是 NSZombie? [英] What is NSZombie?

查看:26
本文介绍了什么是 NSZombie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到有人建议在调试时将 NSZombieEnabled 设置为 true.什么是 NSZombie?它是一个框架吗?设置?

I've seen suggestions saying to set NSZombieEnabled to true while debugging. What is NSZombie? Is it a framework? A setting?

推荐答案

这是一个内存调试辅助工具.具体来说,当您设置 NSZombieEnabled 时,只要对象达到保留计数 0,而不是被释放,它就会将自身变形为 NSZombie 实例.每当这样的僵尸收到消息时,它都会记录警告而不是崩溃或以不可预测的方式行事.因此,您可以调试细微的过度释放/自动释放问题,而无需使用高级工具或在大海捞针中进行艰苦的搜索.

It's a memory debugging aid. Specifically, when you set NSZombieEnabled then whenever an object reaches retain count 0, rather than being deallocated it morphs itself into an NSZombie instance. Whenever such a zombie receives a message, it logs a warning rather than crashing or behaving in an unpredictable way. As such, you can debug subtle over-release/autorelease problems without advanced tools or painstaking needle in haystack searches.

这个名字是一个相当明显的事实,即当对象达到保留计数 0 时,它们通常被认为是死的".在这个设置下,它们继续存在于一个奇怪的半衰期 - 既不是活的,也不是完全死的.很像真正的僵尸,只是它们吃的大脑更少.

The name is a fairly obvious play on the fact that objects are normally considered "dead" when they reach retain count 0. With this setting, they continue to exist in a strange half-life - neither living, nor quite dead. Much like real zombies, except they eat rather fewer brains.

这篇关于什么是 NSZombie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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