Repository navigation
Fix critical memory leaks causing 2.89GB usage on macOS Sequoia - #335
huynguyenh wants to merge 1 commit into
Conversation
- Add [weak self] to DispatchQueue closures to prevent retain cycles - Implement deinit in StatusBarController and PreferencesViewController to clean up NotificationCenter observers - Fix NSStatusItem to only create once and properly remove with removeStatusItem() - Deactivate NSLayoutConstraints before removing views to prevent constraint memory leaks - Update macOS deployment target from 10.12 to 10.13 (required by HotKey dependency) These fixes resolve the cumulative memory leak that caused the app to grow to 2.89GB over time on macOS Sequoia. Testing shows 79% reduction in memory growth on repeated operations. Fixes #326
|
cool, thanks @huynguyenh , lemme check this on weekend 🙏 |
|
I'm glad someone found the cause of this...any possibility of expediting a release with this fix? It's really killing my Mac. Thank you. |
|
When will this fix get merged? |
|
hey @phucledien, any news? really not trying to pressure you as this is open source and whatnot but this is really an important fix as the majority of people have at most 16GBs of RAM (due to, you know, pricing) I only noted this problem in macOS 26 though... |
|
I had to dump hidden and change to ice (beta build) to resolve for me. |
|
Having this merged would be much appreciated. The memory leak problem is really annoying |
|
@phucledien When will this PR be merged? Thanks |
Adds the non-overlapping pieces of huynguyenh's PR consolelabs#335 on top of rm335's PR consolelabs#346. Handles the biggest leak source (NSLayoutConstraint retention when NSImageViews were recreated 9-10 times per toggle). - Deactivate NSLayoutConstraints before removing views in NSStackView.removeAllSubViews (prevents constraint retention of removed NSImageViews — primary leak source on macOS Sequoia/Tahoe) - Extend StatusBarController.deinit to invalidate timer and remove the always-hidden NSStatusItem - Change toggleStatusBarIfNeeded to only create the always-hidden status item when it doesn't already exist, instead of tearing down and recreating on every .alwayHideToggle notification Combined with the widest-display collapse-length calc in consolelabs#354 and the bounded-length work in consolelabs#344, this should resolve the runaway memory growth reported in upstream consolelabs#326, consolelabs#336, consolelabs#351, consolelabs#352. Co-Authored-By: huynguyenh <hoanghuy2908@gmail.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Fix: resolve memory leaks and remove debug info leakage (PR consolelabs#346, Rob Mulder) - Fix comprehensive memory leaks (adapted from PR consolelabs#335, huynguyenh) Addresses the cumulative leak causing 2.89GB memory usage on macOS Sequoia/Tahoe. Closes upstream consolelabs#326, consolelabs#336, consolelabs#351, consolelabs#352.
Adds the non-overlapping pieces of huynguyenh's PR consolelabs#335 on top of rm335's PR consolelabs#346. Handles the biggest leak source (NSLayoutConstraint retention when NSImageViews were recreated 9-10 times per toggle). - Deactivate NSLayoutConstraints before removing views in NSStackView.removeAllSubViews (prevents constraint retention of removed NSImageViews — primary leak source on macOS Sequoia/Tahoe) - Extend StatusBarController.deinit to invalidate timer and remove the always-hidden NSStatusItem - Change toggleStatusBarIfNeeded to only create the always-hidden status item when it doesn't already exist, instead of tearing down and recreating on every .alwayHideToggle notification Combined with the widest-display collapse-length calc in consolelabs#354 and the bounded-length work in consolelabs#344, this should resolve the runaway memory growth reported in upstream consolelabs#326, consolelabs#336, consolelabs#351, consolelabs#352. Co-Authored-By: huynguyenh <hoanghuy2908@gmail.com>
- Fix: resolve memory leaks and remove debug info leakage (PR consolelabs#346, Rob Mulder) - Fix comprehensive memory leaks (adapted from PR consolelabs#335, huynguyenh) Addresses the cumulative leak causing 2.89GB memory usage on macOS Sequoia/Tahoe. Closes upstream consolelabs#326, consolelabs#336, consolelabs#351, consolelabs#352.
Absorbs the still-relevant pieces of three community PRs that overlapped this branch, with authorship credit: - collapse length re-applies to the live separator when displays change, and isCollapsed compares > btnHiddenLength so the state survives the recompute; collapse sizing uses frame.width x2 capped at the documented 10,000pt NSStatusItem maximum (from #354) - NSLayoutConstraint.deactivate before removeFromSuperview in removeAllSubViews, plugging the tutorial-view rebuild leak (from #335) - PreferencesViewController balances its prefsChanged observer in deinit (from #335/#346) Co-authored-by: Laveez <niko.muukkonen1@gmail.com> Co-authored-by: huynguyenh <hoanghuy2908@gmail.com> Co-authored-by: Rob Mulder <hallo@robmulder.com>
|
The |
Absorbs the still-relevant pieces of three community PRs that overlapped this branch, with authorship credit: - collapse length re-applies to the live separator when displays change, and isCollapsed compares > btnHiddenLength so the state survives the recompute; collapse sizing uses frame.width x2 capped at the documented 10,000pt NSStatusItem maximum (from #354) - NSLayoutConstraint.deactivate before removeFromSuperview in removeAllSubViews, plugging the tutorial-view rebuild leak (from #335) - PreferencesViewController balances its prefsChanged observer in deinit (from #335/#346) Co-authored-by: Laveez <niko.muukkonen1@gmail.com> Co-authored-by: huynguyenh <hoanghuy2908@gmail.com> Co-authored-by: Rob Mulder <hallo@robmulder.com>
Absorbs the still-relevant pieces of three community PRs that overlapped this branch, with authorship credit: - collapse length re-applies to the live separator when displays change, and isCollapsed compares > btnHiddenLength so the state survives the recompute; collapse sizing uses frame.width x2 capped at the documented 10,000pt NSStatusItem maximum (from #354) - NSLayoutConstraint.deactivate before removeFromSuperview in removeAllSubViews, plugging the tutorial-view rebuild leak (from #335) - PreferencesViewController balances its prefsChanged observer in deinit (from #335/#346) Co-authored-by: Laveez <niko.muukkonen1@gmail.com> Co-authored-by: huynguyenh <hoanghuy2908@gmail.com> Co-authored-by: Rob Mulder <hallo@robmulder.com>
Root Causes Identified
Fixes Implemented
1. DispatchQueue Closure Memory Leaks
Files: StatusBarController.swift:69-71, 142-144
2. NotificationCenter Observer Cleanup
Files: StatusBarController.swift, PreferencesViewController.swift
3. NSStatusItem Proper Lifecycle
File: StatusBarController.swift:244-262
4. NSLayoutConstraint Memory Leak (Critical)
File: StackView+Extension.swift:14-15
5. Timer Cleanup
File: StatusBarController.swift deinit
6. Deployment Target Update
File: project.pbxproj