官术网_书友最值得收藏!

A brief history of reference counting

Before we get into the details of ARC, we need to rewind the time machine to a previous epoch. The year is 1988, and Objective-C is licensed by NeXT and starting to make its way into their operating system. In 1996, Apple acquires NeXT, alongside the release of OS X, a new and modern toolchain based on Objective-C. Objective-C is a strict superset of C, which means that any valid C code is valid Objective-C code, but unlike C, Objective-C has a modern and efficient memory management engine, based on reference counting.

Reference counting is a technique that accounts for the exact number of references to a particular object that exist at any given time in the memory. Once there are no references, an object, it is deallocated. This is a very different memory management technique, as compared to garbage collection, which you can find in Java or JavaScript.

Many benefits come with the use of reference counting. As there is no garbage collector, there is no need to freeze the process when the memory is cleaned up. It also provides benefits in performance and power management.

Let's go back to the pre-ARC era and write some Objective-C. Even if you're an avid Swift developer, understanding the origins of reference counting will help you to write more correct and efficient code.

Don't be afraid of Objective-C, even if the language is somehow verbose, with a lot of brackets; this is a very fun and performant language to work with.
主站蜘蛛池模板: 禄丰县| 芮城县| 长武县| 玛多县| 阜阳市| 龙州县| 高清| 安吉县| 横峰县| 增城市| 攀枝花市| 化德县| 潼南县| 惠安县| 苏尼特右旗| 冕宁县| 凤阳县| 疏附县| 梓潼县| 邹平县| 克东县| 武乡县| 楚雄市| 黄石市| 沽源县| 安龙县| 安吉县| 任丘市| 沾化县| 长武县| 屯留县| 洞口县| 阿图什市| 平舆县| 六枝特区| 沂南县| 阿拉尔市| 闵行区| 许昌市| 都江堰市| 河北省|