I can confirm that SwiftUI does not clean up something when view's state changes on macOS.
In my app, I change view's state on each mouse move and I can see the allocated memory climbing up and up as I move the mouse around.
The worst is that it's not just an issue of the memory. The app is also getting slower and slower - presumably because SwiftUI keep doing unnecessary work.
Sample view:
@State private var hoverX: CGFloat = 0.0
var body: some View {
Color.blue.frame(width: 50, height: 50)
.offset(x: hoverX, y: 0)
.onMouseMove { point in
hoverX = point.integral.x
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: