Last active
June 6, 2024 07:31
-
-
Save Alexander-Ignition/62a60b6435b624b7e1d095d7f9e6cbb1 to your computer and use it in GitHub Desktop.
Swift struct max size
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
struct User { | |
typealias Ten<T> = (T, T, T, T, T, T, T, T, T, T) | |
let id: Int | |
let name: String | |
let storage: Ten<Ten<Ten<Ten<Ten<UInt64>>>>>? | |
} | |
func structMaxSize() { | |
print("MemoryLayout<User>.size:", MemoryLayout<User>.size) | |
let u = User(id: 0, name: "", storage: nil) | |
print("MemoryLayout<User>.size of value:", MemoryLayout<User>.size(ofValue: u)) | |
let thread = Thread { | |
let u = User(id: 0, name: "", storage: nil) // Thread 10: EXC_BAD_ACCESS (code=2, address=0x17025c000) | |
print("MemoryLayout<User>.size of value:", MemoryLayout<User>.size(ofValue: u)) | |
} | |
// thread.stackSize = 10 // Can't set stack size to a value lower than 16384 (requested 10) | |
print("thread.stackSize:", thread.stackSize) | |
thread.start() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
swiftlang/swift#53485