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

查看:117
本文介绍了什么是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天全站免登陆