[mac] Ghostty slow with time. isReleasedWhenClosed=true seems to help. #13386
|
Ghostty starts out fine for me, but after several days of opening and closing lots of tabs, both Ghostty and WindowServer begin using a lot of CPU. Activity in a terminal (especially frequently changing text or window titles) then makes the problem much worse. Restarting Ghostty clears it, which made this feel like something was building up over time. I added some diagnostics and found that closing a tab removes its terminal session, but part of its macOS window remains alive. I reproduced this reliably in a fresh build: after closing 12 tabs, 12 leftover windows were still being tracked by macOS. I also tested 20 close cycles with the change below, and every closed window was released.
override func close() {
tabTitleEditor.finishEditing(commit: true)
+
+ // NSWindowController disables this by default. Allow AppKit to release
+ // the remaining window after Ghostty has finished closing it.
+ isReleasedWhenClosed = true
+
NotificationCenter.default.post(
name: Self.terminalWillCloseNotification,
object: self
)
super.close()
}Is there a reason Ghostty needs to keep these windows around after they’re closed, or does this look like a safe fix? |
Replies: 4 comments 23 replies
|
|
|
AI assistance disclosure: this investigation was done with Claude Code: it ran the diagnostics ( Independent confirmation on an older stable and a different titlebar style, so this looks neither config-specific nor a recent regression. Env: Ghostty 1.2.2 stable (
On the SurfaceView retain cycle question above: I don't think that explains the window retention. On 1.2.2 the content side deallocates cleanly, exactly 9
Anyone can check their own instance with |
|
I'm going to mark this as closed/complete since we fixed multiple issues. If there are more and specific issues, lets open new discussions. |
I believe this fixes it @mustafa0x: #13601