We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
struct
enum
tuple
Int
Float
Double
Bool
String
Array
Dictionary
Set
class
function
closure
Reference Type
Value Type
값타입 -> Stack영역
참조타입 -> Heap영역
Heap
값 타입
Copy-On-Write: COW
SIL
스위프트의 최적화, 분석과 관련된 하이레벨 중간 언어이다.
Value type vs Reference type in Swift Medium - Swift의 Type과 메모리 저장 공간 Medium - Swift의 메모리 관리(Heap, Stack, ARC) Value Types and Reference Types in Swift
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Type in Swift
Value Type (값타입)
struct
,enum
,tuple
Int
,Float
,Double
,Bool
,String
,Array
,Dictionary
,Set
등 (stuct으로 구현되어있음)Reference Type (참조타입)
class
,function
,closure
등어떤한 경우 적합할까? ⭐️ (쉬운내용이니 차근차근 읽어보기)
Reference Type
보다Value Type
을 선택하는 주된 이유 중 하나는 성능말고도 의도치 않은 데이터의 변경을 방지 할 수 있다.Type에 따른 메모리 할당 공간
Stack
Heap
값타입 -> Stack영역
,참조타입 -> Heap영역
1:1 매칭이라고 생각할 것이다.Value Type이 Heap 메모리에 할당되는 경우
Array
,Dictionary
,Set
,String
(collection of characters)과 같은 가변 길이 Collection들은Heap
에 저장해서 사용된다.Array
,String
등은 기본적으로struct
로 구현된값 타입
이기 때문에 인스턴스마다 유니크한 데이터를 가져야 한다.Copy-On-Write: COW
라는 기법을 사용한다.Copy-On-Write: COW
Reference Type값이 Stack 메모리에 할당되는 경우
SIL
에 의해 (추후설명) 컴파일 타임에 결정 할 수 있는 경우 스택에 할당 할 수 있다.Swift Intermediate Language (SIL)
요약
값타입 -> Stack영역
,참조타입 -> Heap영역
이다는 더이상 틀린 말❗️이다.SIL
에 의한 승격화로 이루어 진다.참조
Value type vs Reference type in Swift
Medium - Swift의 Type과 메모리 저장 공간
Medium - Swift의 메모리 관리(Heap, Stack, ARC)
Value Types and Reference Types in Swift
The text was updated successfully, but these errors were encountered: