Hi team,
First of all, thank you for your great work on this library — it’s been very helpful in my project.
I’ve encountered a memory leak in DotLottieAnimationView caused by a strong reference cycle between DotLottieAnimationView and its Coordinator.
Both DotLottieAnimationView and Coordinator hold strong references to each other:
public class DotLottieAnimationView: UIView, DotLottie {
private var coordinator: Coordinator!
private func setupMetalView() {
self.coordinator = Coordinator(self, mtkView: mtkView)
}
}
public class Coordinator: NSObject, MTKViewDelegate {
private var parent: DotLottie
init(_ parent: DotLottie, mtkView: MTKView) {
self.parent = parent
}
}
Because parent in Coordinator is a strong reference and DotLottieAnimationView holds coordinator strongly, neither object is ever deallocated.
This becomes a significant issue when DotLottieAnimationView is used in a scrolling UICollectionView or UITableView (e.g., a grid of animations). Over time, hundreds of DotLottieAnimationView instances accumulate in memory and are never released.
Best regards,
Abdulrahman Qasem
Hi team,
First of all, thank you for your great work on this library — it’s been very helpful in my project.
I’ve encountered a memory leak in DotLottieAnimationView caused by a strong reference cycle between
DotLottieAnimationViewand itsCoordinator.Both DotLottieAnimationView and Coordinator hold strong references to each other:
Because parent in Coordinator is a strong reference and DotLottieAnimationView holds coordinator strongly, neither object is ever deallocated.
This becomes a significant issue when DotLottieAnimationView is used in a scrolling UICollectionView or UITableView (e.g., a grid of animations). Over time, hundreds of DotLottieAnimationView instances accumulate in memory and are never released.
Best regards,
Abdulrahman Qasem