Skip to content

fix(macos): correct window ownership and superclass deallocation - #1368

Open
Tunglies wants to merge 1 commit into
tauri-apps:devfrom
Tunglies:fix/macos-window-ownership
Open

Tunglies wants to merge 1 commit into
tauri-apps:devfrom
Tunglies:fix/macos-window-ownership

Conversation

@Tunglies

@Tunglies Tunglies commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Repeatedly creating and closing windows on macOS retains native window objects and causes excessive memory growth.

The window creation path adds an extra retain to an already-owned alloc/init result. The custom view and window delegate deallocators also omit superclass deallocation.


Counts and memory below are measured after cooldown. Window counts include both TaoWindow and NSKVONotifying_TaoWindow. (Operation for 100 times)

Scenario Revision Remaining windows Remaining delegates Remaining views Live heap bytes Physical footprint
Decorated, hidden Baseline 100 100 100 40,972,608 55.6M
Decorated, hidden Fixed 0 0 0 3,437,168 13.0M
Borderless, hidden Baseline 100 100 100 4,490,512 12.2M
Borderless, hidden Fixed 1 0 1 1,978,944 8306K

The change removes the one-object-per-cycle accumulation observed in the baseline. The borderless scenario retains one window and its view, with no delegate remaining; complete native-object release is not claimed.

The Borderless, hidden fix still remained 101 might due to appkit native behavior.


Related & Close: #1327, #1363

@Tunglies
Tunglies requested a review from a team as a code owner October 8, 2026 09:17
@Tunglies

Copy link
Copy Markdown
Contributor Author

Any plan to forward? It's quite impact to some application that has feature likely destroy webview then create new one as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NSWindow, wry's parent view and TaoWindowDelegate are never released after a window is closed (macOS)

2 participants