在project-setting中找到 “Run Static Analyzer” 键,然后把值修改为“YES”.这样在编码的时候,xcode就可以自动为我们检查内存泄露了.
泄露
1.Logic error :The left operand of "==" is a grabage value
原因 "=="左侧的变量为初始化
2.Potential leak of an object allocated on line 456,
Method returns an Objective-C object with a+1 retain count
通常为定义的对象未释放,改成autorelease,或者自己去释放
3.Object sent -autorelease too many times
Method returns an Objective-c object with a +0 retain count
定义对象为autorelease类型的,使用替代可以解决