SDWebImageSwiftUI: Memory issue when caching too many GIFs in List / LazyVStack
Clearing memory caches manually doesn’t help. Reproduced in 2.0.0 & 2.0.1.
I used 70 gifs (5-7 MB each) to reproduce with my 4GB memory iPhone.
import SwiftUI
import SDWebImageSwiftUI
struct ContentView: View {
let gifs = // bunch of gifs here
var body: some View {
ScrollView {
LazyVStack {
ForEach(gifs, id: \.hashValue) { gif in
WebImage(url: URL(string: gif))
.resizable()
.indicator(.progress)
.scaledToFit()
}
}
}
}
}
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 26
@tatsuz0u Thank you for the example code, I’m able to reproduce with LazyVStack. A little bit hacky but can we do something similar to this:
then use
seems does not cause the memory issue.
onevcat said the LazyVStack is buggy. So I’ll bring a List reproducible demo next time.
Thanks for your reply 😃
I finished the profile, no leaks and only one
SDAnimatedImagePlayer. It crashed due to memory issue anyway.I can upload the trace file to Mega, or full allocation summary screenshots instead?
Update: The
.purgeablemodifier doesn’t help.