Open bummoblizard opened 1 year ago
Same issue in markdown previews.
private class Storage: ObservableObject {
@Published var isLoading: Bool = true
let pdfView = PDFView()
deinit {
print("PDFStorage Deinit")
}
}
Deinit is never called.
By storing a PDFView instance in an environment object (MainApp.editors), we are creating a retain cycle between the view and the object. That's why it's never released.
See Scenario 4 in this article: https://tiagolopes.blog/2022/11/01/when-does-a-swiftui-environment-get-retained/
Multiple scenes also leaks the ObservableObjects including all extensions. Not sure what can be done about it.
I think it's about the self cpaturing closures that we use a lot in MainApp. I'll look into it.
I think it's about the self cpaturing closures that we use a lot in MainApp. I'll look into it.
It will take quite a lot of efforts to resolve this. Let's fix it in 1.4.1.
There seems to be a memory leak in PDF previews.