일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- MG더뱅킹정기예금
- 예금
- 청약
- 사전청약
- CHAT GPT
- ndk r24
- 새마을금고
- KB
- Mac
- 3rd framework
- 고금리
- JetPack
- java
- arm-linux-androideabi
- RETROFIT
- EditText
- Android Studio
- ndkVersion
- Andorid
- ChatGPT
- kotlin
- 용산 호반써밋 에이디션
- Swift
- ios
- Data Binding
- Android
- audio record
- gradle
- BindingAdapter
- 달러예금
- Today
- Total
pear
[iOS]Swift Value Memory Study 본문
스위프트 메모리 타입 요약
[High]
Stack
Dynamic
Heap
BSS
GVAR
TEXT
[Low]
value type
dump(variable:)
dump(with:)
dump(object:)
EX) String
stack 16byte 할당
heap 문자열 할당(짧은 문자열은 stack영역도 사용)
dump(with:)
copy-on-write
Collection Heap
print(MemoryLayout<String>.size)//16
var fString = "a"
var sString = "bb"
print(MemoryLayout.size(ofValue: fString)) //16
print(MemoryLayout.size(ofValue: sString)) //16
주어진 instance 의 memory footprint 를 리턴하고, pointer나 class 인스턴스에 대해서는 reference data의 size 와 상관없이 동일한 memory footprint 를 return 한다.
copy on write
수정 시점에는 copy-object를 사용하고 instance공유(origin-object 메모리 주소를 참조) 수정 후 변경된 데이터를 반영
고정된 Reference Type Value 메모리는 Heap영역에 할당 될 수도 있다.
스위프트 타입별 메모리 분석 실험
struct와 class 가 메모리 영역을 어디를 사용하는지 분석한 실험 결과
medium.com
The story of one mother & two sons: value type vs reference type in Swift
Swift is a mother?and it has two sons ?- Value Type ??♀️Reference Type ?♂️But what are their characteristics??♂️ Do they behave the same or opposite to each other? ?♂️ Swift is a multi-paradigm programming language developed by
www.freecodecamp.org
https://swiftrocks.com/memory-management-and-performance-of-value-types
Memory Management and Performance of Value Types
It's very likely that you asked yourself at least once in your iOS career what's the difference between a struct and a class. While realistically the choice between using one or another always boils down to value semantics versus reference semantics, the p
swiftrocks.com
'iOS > swift' 카테고리의 다른 글
[iOS] UI portrait fixed(세로 고정) (0) | 2023.06.30 |
---|---|
[iOS] record(swift) 응용 (0) | 2023.06.16 |
[iOS]DispatchQueue.global (0) | 2023.03.08 |
[swift]3rd part framework - Undefined symbols for architecture (0) | 2022.05.27 |
iOS issue - Error creating LLDB target at path (0) | 2022.01.20 |