<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Automatic Reference Counting on Kelly Dev</title><link>https://kelly-chui.github.io/tags/automatic-reference-counting/</link><description>Recent content in Automatic Reference Counting on Kelly Dev</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 21 Aug 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://kelly-chui.github.io/tags/automatic-reference-counting/index.xml" rel="self" type="application/rss+xml"/><item><title>The Swift Programming Language. Automatic Reference Counting (1)</title><link>https://kelly-chui.github.io/posts/the-swift-programming-language-50-automatic-reference-counting-1/</link><pubDate>Tue, 15 Aug 2023 00:00:00 +0000</pubDate><guid>https://kelly-chui.github.io/posts/the-swift-programming-language-50-automatic-reference-counting-1/</guid><description>&lt;figure class="theme-image"&gt;
&lt;img
class="theme-image__image theme-image__image--light"
src="https://kelly-chui.github.io/images/assets/swift-logo-light.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;img
class="theme-image__image theme-image__image--dark"
src="https://kelly-chui.github.io/images/assets/swift-logo-dark.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;/figure&gt;
&lt;h2 id="automatic-reference-counting"&gt;Automatic Reference Counting&lt;/h2&gt;
&lt;p&gt;스위프트는 &lt;em&gt;자동 참조 카운팅&lt;/em&gt;(ARC)을 사용하여 앱의 메모리 사용량을 추적하고 관리한다. 대부분의 경우에, 스위프트에서 메모리 관리는 &amp;ldquo;그냥 작동&amp;quot;하고, 메모리 관리를 직접 할 생각을 하지 않아도 된다. ARC는 클래스 인스턴스가 더 이상 필요하지 않게 되었을 때, 자동적으로 해당 메모리를 비우게 된다.&lt;/p&gt;
&lt;p&gt;하지만, 경우에 따라 ARC는 메모리 관리를 위해 코드 내부에서의 관계**(주: 원문은 relationships between parts of your code, 코드 부분들 간의 관계)** 에 대한 정보를 요구할 때가 있다. 이 챕터는 이러한 상황들을 설명하고, 어떻게 ARC가 앱의 메모리를 관리하는지를 보여준다.&lt;/p&gt;</description></item><item><title>The Swift Programming Language. Automatic Reference Counting (2)</title><link>https://kelly-chui.github.io/posts/the-swift-programming-language-51-automatic-reference-counting-2/</link><pubDate>Wed, 16 Aug 2023 00:00:00 +0000</pubDate><guid>https://kelly-chui.github.io/posts/the-swift-programming-language-51-automatic-reference-counting-2/</guid><description>&lt;figure class="theme-image"&gt;
&lt;img
class="theme-image__image theme-image__image--light"
src="https://kelly-chui.github.io/images/assets/swift-logo-light.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;img
class="theme-image__image theme-image__image--dark"
src="https://kelly-chui.github.io/images/assets/swift-logo-dark.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;/figure&gt;
&lt;h3 id="resolving-strong-reference-cycles-between-class-instances"&gt;Resolving Strong Reference Cycles Between Class Instances&lt;/h3&gt;
&lt;p&gt;스위프트는 클래스 타입 프로퍼티로 작업할 때 강한 참조 사이클을 해결하는 두 가지 방법으로 약한 참조와 미소유 참조를 제공한다.&lt;/p&gt;
&lt;p&gt;약한 참조와 미소유 참조는 참조 사이클 내부의 한 인스턴스가 다른 인스턴스를 강하게 붙잡지 않고 참조할 수 있게 해준다. 그리고는 그 인스턴스들은 서로를 강한 참조 사이클 없이 참조할 수 있게 된다.&lt;/p&gt;
&lt;p&gt;다른 인스턴스의 수명이 더 짧을 때 약한 참조를 사용한다. — 즉 다른 인스턴스가 먼저 할당 해제되는 경우이다. 이전의 &lt;code&gt;Apartment&lt;/code&gt; 예시에서, 아파트의 라이프 사이클 중간에 거주자가 없는 것은 충분히 가능한 일이므로 약한 참조는 이러한 경우의 참조 사이클을 깨뜨리는데 적합하다. 반대로, 미소유 참조를 사용하는 것은 다른 인스턴스가 같거나 더 긴 수명을 가지고 있을때 사용한다.&lt;/p&gt;</description></item><item><title>The Swift Programming Language. Automatic Reference Counting (3)</title><link>https://kelly-chui.github.io/posts/the-swift-programming-language-52-automatic-reference-counting-3/</link><pubDate>Mon, 21 Aug 2023 00:00:00 +0000</pubDate><guid>https://kelly-chui.github.io/posts/the-swift-programming-language-52-automatic-reference-counting-3/</guid><description>&lt;figure class="theme-image"&gt;
&lt;img
class="theme-image__image theme-image__image--light"
src="https://kelly-chui.github.io/images/assets/swift-logo-light.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;img
class="theme-image__image theme-image__image--dark"
src="https://kelly-chui.github.io/images/assets/swift-logo-dark.svg"
alt="Swift logo"
loading="lazy"
decoding="async"
&gt;
&lt;/figure&gt;
&lt;h3 id="strong-reference-cycles-for-closures"&gt;Strong Reference Cycles for Closures&lt;/h3&gt;
&lt;p&gt;두 클래스 인스턴스의 프로퍼티들이 서로를 강한 참조하면서 강한 참조 사이클이 만들어지는지를 이전에 보았고, 약한 참조와 미소유 참조가 이러한 강한 참조 사이클을 깨뜨리는 것도 보았다.&lt;/p&gt;
&lt;p&gt;강한 참조 사이클은 클래스의 인스턴스에 클로저를 할당하고, 해당 클로저의 본문에서 그 인스턴스를 캡처할때도 발생한다. 이러한 캡처는 &lt;code&gt;self.someProperty&lt;/code&gt;처럼 그 클로저가 해당 인스턴스의 프로퍼티에 접근하거나, &lt;code&gt;self.someMethod()&lt;/code&gt;처럼 해당 인스턴스의 메소드에 접근할 때 발생한다. 두 경우 모두, 이러한 접근으로 그 클로저가 &lt;code&gt;self&lt;/code&gt;를 &amp;ldquo;캡처&amp;quot;할때, 강한 참조 사이클을 생성하게 된다.&lt;/p&gt;</description></item></channel></rss>