struct ContentView: View {
var body: some View {
ScrollView(.vertical) {
LazyVStack(spacing: 0) {
ForEach(0..<10000) { index in
// If VStack remove, memory issue occur
// VStack {
CustomView(index: index)
// }
}
}
}
}
}
struct CustomView: View {
var index: Int
var body: some View {
VStack {
Text("\(index)")
}
}
}
I wrapped it into a shorter and simpler version, but it still works.
At first, I struggled to figure out why the initial code was causing lag. After investigating with the Debug Memory Graph, I found that the generated custom view’s memory was not being released properly.
This seemed strange because I was using the custom view inside a LazyHStack.
So, I tried various approaches to resolve the issue.
In the Debug Memory Graph, I started suspecting that SwiftUI’s built-in views like VStack and HStack might be affecting memory management. To test this, I wrapped my custom view inside a VStack, and the memory issue disappeared.
However, I want to understand why I need to include the custom view inside a VStack for proper memory management.
(I simplified this code by wrapping it into a shorter version. However, in a real project, the custom view is more complex, and the data list contains more than 10,000 items. This caused severe lag.)
xcode: 16.2, iOS 18, iOS 16
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'd like to display a list of Keychain items using Touch ID when focusing on a text field, as shown in the image below. I've looked through the documentation but couldn't find an API that can produce the desired effect as shown in the image.
It seems to me that there isn't an API for this and I would need to implement it manually. However, I'm wondering if there might be an API that I'm not aware of.
References: https://developer.apple.com/documentation/localauthentication ,
https://developer.apple.com/documentation/localauthenticationembeddedui/laauthenticationview