mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-20 10:46:07 +03:00
Merge pull request #375 from mitchellh/macos-free
macos: break reference cycle to window to allow window to free memory
This commit is contained in:
@ -11,4 +11,14 @@ class PrimaryWindowController: NSWindowController {
|
|||||||
guard let manager = self.windowManager else { return }
|
guard let manager = self.windowManager else { return }
|
||||||
manager.triggerNewTab(for: window)
|
manager.triggerNewTab(for: window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
// I don't know if this is the right place, but because of WindowAccessor in our
|
||||||
|
// SwiftUI hierarchy, we have a reference cycle between view and window and windows
|
||||||
|
// are never freed. When the window is closed, the window controller is deinitialized,
|
||||||
|
// so we can use this opportunity detach the view from the window and break the cycle.
|
||||||
|
if let window = self.window {
|
||||||
|
window.contentView = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user