All posts
Post
AppKit windows that “close” but keep their NSViewController trees alive can turn into scrolling jank and quiet memory creep. The fix starts with seeing the actual owners, not guessing from heap size.
- Use
Debug Memory Graphto trace strong-reference paths from anNSViewControllerto theNotificationCentertoken, timer, or closure that’s holding it. - Pair it with
Instruments > Allocationsfor time-based growth; short spikes won’t always appear in a snapshot. - Teardown where it reliably runs during close:
NSWindowDelegate.windowWillClose(_:)(remove observers, cancel timers), not only indeinit. - Prefer owned, cancelable timers like
DispatchSourceTimerover repeatingTimertied to the runloop. - Audit
NSTableView/NSCollectionViewadapters: closure callbacks that captureselfcan