在新发布的ios5中,有个很吸引眼球的特性就是“Automatic Reference Counting”,简单来说就是内存自动回收,看起来似乎是平时开发中遇到的各种内存问题的福音,仔细了解了一下,似乎没有那么美好:
1。 需要iOS5才支持
2。 很多引用的类库暂时还不支持.麻烦的是对大多数第三方库需要加禁用arc的编译flag,因为大多都因为兼容性还在使用手动内存管理。
而且当你开启了ARC后, 如果使用传统的手工 release 就是报错 \'release\' is unavailable: not available in automatic reference counting modeAutomatic Reference Counting forbids explicit message send of \'release\'
你可以按照如下方法关闭它
Xcode 4.2: 点击项目后,
Build Settings -> Apple LLVM compiler 3.0 - Language -> Objective-C Automatic Referencing Counting, 默认是YES 设置为NO即可。
但实际上 ARC确实比手动释放快,而且不会发生内存泄漏的情况,具体可以参考这里
http://clang.llvm.org/docs/AutomaticReferenceCounting.html
http://stackoverflow.com/questions/6385212/how-does-the-new-automatic-reference-counting-mechanism-work
一篇深入讨论 ARC的文章
http://longweekendmobile.com/2011/09/07/objc-automatic-reference-counting-in-xcode-explained/
相关文章:
- iOS开发--关闭ARC 2021-08-16
- iOS ARC的打开 与 关闭 2021-08-16
- 关闭win10的自动更新功能 2021-12-29
- 关闭windows10的自动更新功能 2021-06-29
- 如何关闭iTunes 更新,还原iPhone、iPad 自动备份功能 ? 2021-12-15
- macos关闭更新功能 - 季枫 2021-12-14
- 浏览器如何打开和关闭JS功能 2021-08-09
- 如何关闭联想电脑的动态屏保功能? 2021-12-08