NSZombieEnabled使用
来源:互联网 发布:php soap 传xml 编辑:程序博客网 时间:2024/06/15 04:43
我们做iOS
比如你对已释放的对象发送消息时就会出现,EXC_BAD_ACCESS,再如release
比如
- static NSMutableArray*array;
- -(void)viewDidLoad
- {
- [superviewDidLoad];
- array= [[NSMutableArray alloc]initWithCapacity:5];
- [array release];//释放掉该数组
- }
- - (void)viewWillAppear:(BOOL)animated{
- [array addObject:@"Hello"];//使用释放掉的数组
- }
不过NSZombieEnabled
对
*** -[__NSArray addObject:]:message sent to deallocated instance 0x6557370
如何设置
Xcode3
1.
2.
3.
Xcode4
你可以点击 Xcode4 菜单 Product -> Edit Scheme-> Arguments, 然后将点击”加号”, 将 NSZombieEnabled 参数加到Environment Variables 窗口中, 后面的数值写上 ”YES”.
或者在 Xcode4 菜单
Xcode4
另外再说一下,如果没有为
- static NSMutableArray*array;
- -(void)viewDidLoad
- {
- [super viewDidLoad];
- array= [[NSMutableArray alloc]initWithCapacity:5];
- [array release];
- [array addObject:@"Hello"];//之所以不会crash,是在于事件周期未完,内存回收机制还没有执行,没有真正的回收掉array的对象内存。
- NSLog(@"%@",[array objectAtIndex:0]);
- }
但是一旦加上了NSZombieEnable
*** -[__NSArrayM addObject:]:message sent to deallocated instance 0x6557370
即使该array
最后提醒NSZombieEnabled只能在调试的时候使用,千万不要忘记在产品发布的时候去掉,因为NSZombieEnabled不会真正去释放dealloc对象的内存,一直开启后果可想而知,自重!
注:
1.苹果官方的Mac OS X Debugging Magic,详细讲述了最为一个高级苹果程序员应该具备的调试技巧
2.其实还可以在Instruments中开启NSZombie选项,这样就可以在Instruments中直接查看crash时候的callstack了:http://www.markj.net/iphone-memory-debug-nszombie/
本文转载自:http://blog.csdn.net/likendsl/article/details/7566305
- NSZombieEnabled使用
- NSZombieEnabled
- XCode4设置NSZombieEnabled
- NSZombieEnabled惹的祸
- xCode4里面设置NSZombieEnabled
- xCode4里面设置NSZombieEnabled
- 设置NSZombieEnabled和MallocStackLogging
- 设置NSZombieEnabled和MallocStackLogging
- 设置NSZombieEnabled和MallocStackLogging
- xCode4里面设置NSZombieEnabled
- NSZombieEnabled 解决EXC_BAD_ACCESS错误
- NSZombieEnabled的注意事项
- NSZombieEnabled 定位 EXC_BAD_ACCESS 错误
- xCode4里面设置NSZombieEnabled
- xCode4设置NSZombieEnabled
- 设置NSZombieEnabled和MallocStackLogging
- 设置NSZombieEnabled捕捉错误
- 用NSZombieEnabled帮助解决EXC_BAD_ACCESS
- Objective-C中关于类反射的实现
- 制作一张简单的网页(HTML+CSS+JS) 【3】
- 对称加密和非对称加密
- CoreData简介
- synthesize和dynamic
- NSZombieEnabled使用
- XCode的控制台调试命令
- 通过终端,查看sqlite3的存储文件
- NSURLCache缓存使用简介
- 获取GIF图片中所有的单图
- 基于内容的图像检索引擎
- VC/MFC实现版本的在线升级提示和下载(服务器配置文件的方法)
- mac idea 快捷键大全
- 堆与堆排序