Łukasz Rutkowski on Nostr: Discovered interesting SwiftUI memory leak bug in iOS 17 around creation of ...
Discovered interesting SwiftUI memory leak bug in iOS 17 around creation of StateObject (FB13108791). If you pass it a value initialized not inline it will never be freed:
This works:
self._myClass = StateObject(wrappedValue: MyClass())
This causes memory leak:
let myClass = MyClass()
self._myClass = StateObject(wrappedValue: myClass)
#SwiftUI #iOSDev #iOS17Beta8
Published at
2023-09-03 09:04:22Event JSON
{
"id": "13edb7fadfcb3632a6a348ab0a47c4ddff29a34175242b49ecce85bda4fad242",
"pubkey": "d100dbdd94fb2ffe2342e71946698564335c0e89d3570adfa1561b8548e3bf2e",
"created_at": 1693731862,
"kind": 1,
"tags": [
[
"t",
"swiftui"
],
[
"t",
"iosdev"
],
[
"t",
"ios17beta8"
],
[
"proxy",
"https://mastodon.world/users/luckkerr/statuses/111000411349644001",
"activitypub"
]
],
"content": "Discovered interesting SwiftUI memory leak bug in iOS 17 around creation of StateObject (FB13108791). If you pass it a value initialized not inline it will never be freed:\n\nThis works:\nself._myClass = StateObject(wrappedValue: MyClass())\n\nThis causes memory leak:\nlet myClass = MyClass()\nself._myClass = StateObject(wrappedValue: myClass)\n\n#SwiftUI #iOSDev #iOS17Beta8\n\nhttps://s3.eu-central-2.wasabisys.com/mastodonworld/media_attachments/files/111/000/411/231/591/628/original/9af8af1efc0e4db6.png",
"sig": "2be831cf4c373b4aee030b6984b8b568424af80ffaa7b2a6da0a0ed7b394fb3a9fc6479162852352e8bb36c0f867637fc8583a0bc121f1f615e5593323cdc722"
}