问题描述
当我从C ++(和小Java)转移到Objective C(iOS)时,我很难理解iOS中的内存管理。但现在这一切看起来很自然,我知道保留,自动释放,复制和发布的东西。在阅读了ARC之后,我想知道使用ARC有什么好处,或者只是你不必担心内存管理。在转向ARC之前,我想知道如何转向ARC。
When I moved to Objective C (iOS) from C++ (and little Java) I had hard time understanding memory management in iOS. But now all this seems natural and I know retain, autorelease, copy and release stuff. After reading about ARC, I am wondering is there more benefits of using ARC or it is just that you dont have to worry about memory management. Before moving to ARC I wanted to know how worth is moving to ARC.
- XCode有转换为Objective C ARC菜单。转换是否那么简单(没什么可担心的)?
- 它是否有助于我减少我的应用程序内存占用空间,内存泄漏等(不知何故?)
- 它对我的应用程序有多大的测试影响?
- 什么是非显而易见的优势?
- 移动到它的任何不利之处?
- XCode has "Convert to Objective C ARC" menu. Is the conversion is that simple (nothing to worry about)?
- Does it help me in reducing my apps memory foot-print, memory leaks etc (somehow ?)
- Does it has much testing impact on my apps ?
- What are non-obvious advantages?
- Any Disadvantage of moving to it?
推荐答案
以下是我对ARC的具体看法:
Here's my specific take on ARC:
这很简单。有用。用它。正如Kevin Low指出的那样,你需要经历并修复使用Core Foundation对象的位。这只需要健康绑定但是。
It's simple. It works. Use it. As Kevin Low points out though, you will need to go through and fix up the bits where you use Core Foundation objects. That will just require a healthy lashing of __bridge
or __bridge_transfer
though.
不,不是真的。好的,有点儿。它有助于减少以前编码错误的内存泄漏。它不会减少内存占用。
Nope, not really. OK, sort of. It will help reduce memory leaks where you have coded incorrectly previously. It won't reduce memory footprint.
无论如何。
未来。将会有更多的奖励,即编译器对如何计算引用的对象提供了复杂的知识。例如,ARC提供了可爱的优化已经非常好了。
The future. There'll be more to come on the bonus that the compiler taking an intricate knowledge of how objects are reference counted gives. For example ARC provides the lovely objc_retainAutoreleasedReturnValue
optimisation already, which is very nice.
无论如何。
请接受我的话并开始使用弧。没有理由(IMO)没有,因此优势肯定超过了劣势!
Please take my word for it and start using ARC. There's no reason (IMO) not to, thus the advantages definitely out-weigh the disadvantages!
深入了解ARC如何工作或许有助于说服你这很好,请看看我的博客文章在ARC的引擎盖下看看 - ,,& 。
For an in-depth look at how ARC works to perhaps help convince you that it's good, please take a look at my blog posts entitled "A look under ARC's hood" - here, here, here & here.
这篇关于ARC,值得与否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!