-
-
Save godrm/a2bff14ed36a98aa62f934a6ad426617 to your computer and use it in GitHub Desktop.
Memory Dump For Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
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()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment