I've pretty much completed creating my first macOS SwiftUI app. It's working fine but after using it for more than 10 minutes I noticed a dramatic slow down and big memory footprint. I condensed the problem down into the following minimal example, which is a full SwiftUI app for both macOS and iOS.
On macOS after just a few clicks in the NavigationView I'm getting a memory footprint of 1GB and performance decreases. Profiling the app with Leak Detector also shows a massive amount of leaks in SwiftUI classes. Compiling the same app for iOS stays at a reasonable footprint of 50 MB even after using it for a while. This bug prevents me from properly using my app. I submitted a bug report in Feedback Assistant about a month ago with no answer or reaction. Please help! How can such a huge leak stay unnoticed.
I'm running the latest Big Sur 11.2.1 and Xcode 12.4
Code Block language Swift import SwiftUI @main struct TestApp: App { @State var selection: Int? var body: some Scene { WindowGroup { NavigationView { List(0...10, id: \.self) { element in NavigationLink(destination: VeryComplexView(text: "\(element)"), tag: element, selection: $selection) { Text("\(element)") } } } } } } struct VeryComplexView: View { let text: String var body: some View { HStack { ForEach(1...10, id: \.self) { _ in List(1...5000, id: \.self) { element in Text("\(text) \(element)") } } } } }
On macOS after just a few clicks in the NavigationView I'm getting a memory footprint of 1GB and performance decreases. Profiling the app with Leak Detector also shows a massive amount of leaks in SwiftUI classes. Compiling the same app for iOS stays at a reasonable footprint of 50 MB even after using it for a while. This bug prevents me from properly using my app. I submitted a bug report in Feedback Assistant about a month ago with no answer or reaction. Please help! How can such a huge leak stay unnoticed.
I'm running the latest Big Sur 11.2.1 and Xcode 12.4