728x90
https://www.raywenderlich.com/966538-arc-and-memory-management-in-swift#toc-anchor-003
ARC and Memory Management in Swift
In this tutorial, you’ll learn how ARC works and how to code in Swift for optimal memory management. You’ll learn what reference cycles are, how to use the Xcode 10 visual debugger to discover them when they happen and how to break them using an exampl
www.raywenderlich.com
Swift Object Lifetime
Swift object의 lifetime은 5 단계로 이루어진다.
- Allocation: stack이나 heap영역에서 메모리를 가져온다.
- Initialization: init 코드를 실행한다.
- Usage
- Deinitialization: deinit 코드를 실행한다.
- Deallocation: 메모리를 stack이나 heap 영역에 반환한다.
allocation과 deallocation 과정에 대한 직접적인 hook는 존재하지 않지만, init과 deinit에서 print함수를 이용해서 해당 프로세스들을 관찰하기 위한 proxy로 활용할 수 있다.
728x90
'Swift' 카테고리의 다른 글
| [Swift] Generic where clause 사용 시 '==' vs ':' (0) | 2022.09.25 |
|---|---|
| [Swift] JSON Decoding, Encoding (0) | 2022.09.05 |
| [Swift] Weak vs Unowned Reference (0) | 2022.08.20 |
| [Swift] 특정 class 상속받아야만 protocol을 채택하도록 제약 걸기 (0) | 2022.07.16 |
| [Swift] Method Swizzling (0) | 2022.07.09 |
댓글