Skip to content

fix: free the launch window's tab manager when it closes - #392

Merged
arzafran merged 2 commits into
mainfrom
fix/launch-window-leak
Sep 30, 2026
Merged

arzafran merged 2 commits into
mainfrom
fix/launch-window-leak

Conversation

@arzafran

Copy link
Copy Markdown
Member

What this does

Closing the window that opens at launch no longer leaves its tabs, workspaces and splits in memory. After #390, every other window was freed on close, but the launch window left one full set behind each time.

Three things held it:

  1. Workspace menu (Sources/ProgramaApp.swift): the menu's button actions captured the window's tab manager and workspace, and SwiftUI keeps the menu around. The actions now look up the active tab manager when clicked, like the other menu items.
  2. Sidebar resizer (Sources/ContentView+SidebarResizer.swift): teardown scheduled a deferred cursor release stored in view state. Once the view was gone, it never cleared, and it held the view and its tab manager. Teardown now releases the cursor right away.
  3. Directory tracking (Sources/ProgramaConfig.swift): a Combine pipeline kept the last selected workspace. It now keeps only the workspace id and its directory publisher.

Measured

Tagged Debug build, heap counts of Workspace / TabManager / BonsplitController / SidebarState, 8 s after each close.

State Before After
Launch window + one new window, then close the launch window 3/3/3/2 2/2/2/2
3 cycles of reopen, new window, close the launch window grew each cycle 2/2/2/2 every cycle

The one extra tab manager after a close is the spare that PrimaryTabManagerStore keeps for the next launch window, by design.

Test plan

  • Workspace menu: Pin, Move Up, Move to Window and Close Workspace act on the frontmost window, including after closing and reopening the launch window.
  • Dragging the sidebar resizer still shows and releases the resize cursor.
  • Switching workspaces still updates the directory used for project config.

@arzafran
arzafran merged commit 5920b63 into main Sep 30, 2026
13 checks passed
@arzafran
arzafran deleted the fix/launch-window-leak branch September 30, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant