스위프트 타입별 메모리 분석 실험
struct와 class 가 메모리 영역을 어디를 사용하는지 분석한 실험 결과
medium.com
LLDB 메모리 덤프 저장
XCode Console에서 저장하고 싶은 부분에 브레이크 포인트 설정 후 아래 명령어 실행
(lldb) process save-core /Users/xxxxxxxx/memoryData.dump
[iTerm2 에서 열어보기]
> lldb -c memoryData.dump
(lldb) gui
[LLDB에서 덤프파일 읽기]
> lldb
(lldb) target create --core "momoryData.dump"
(lldb) gui
[메모리 주소 알아보기]
struct Memory {
@inlinable static func dump<T>(variable: inout T) {
withUnsafePointer(to: &variable) { print($0) }
}
@inlinable static func dump(with: UnsafeRawPointer) {
let address = Int(bitPattern: with)
print(String(format:"%018p", address))
}
@inlinable static func dump(object: AnyObject) {
print(Unmanaged.passUnretained(object).toOpaque())
}
}
//////////////////////////////////////////////
Memory.dump(variable: &jsParam)
결과 : 0x000000016d2c21b8
'Swift > 문법' 카테고리의 다른 글
[Swift] String split과 components 차이점 (0) | 2024.04.19 |
---|---|
[SWIFT] PropertWrapper Comparable 프로토콜 사용 예제 (0) | 2023.10.12 |
[XCODE] LLDB 특정 DATA 메모리 덤프 저장하기 (0) | 2023.09.06 |
[XCODE]LLDB 명령어 (디버깅 명령어) (0) | 2023.09.06 |
[SWIFT]Set (0) | 2023.07.26 |