Hello,
I have a memory leak problem with Color and CGColor. I have a project in which I need to be able to change the colors of different elements with colorPicker and while monitoring with instrument I realized that I had memory leak. To understand, I've done much smaller test projects, and each time there are memory leaks. And finally I tried something very basic, the code below, and it also produces memory leaks as soon as you change the color more than 2 times. I'm running xcode 15.4, sonoma 14.5, and mac book pro 13, m1, 2020.
Is there a known bug with colorPicker and type Color?
The very simple code should not produce a memory leak:
File one :
`import SwiftUI
struct MainViewSimple: View {
@State var couleurTexte:Color = .blue
var body: some View {
Text("Hello, World!")
.foregroundStyle(couleurTexte)
SelectColor(couleurTexte: $couleurTexte)
}
}
#Preview { MainViewSimple() }`
File two :
`import SwiftUI
struct SelectColor: View {
@Binding var couleurTexte:Color
var body: some View {
ColorPicker("couleur du texte", selection: $couleurTexte)
}
}
#Preview { SelectColor(couleurTexte: .constant(.blue)) }`