Skip to content

fix: memory leak in dismissal polling due to undrained autoreleasepool#65

Open
A0150315 wants to merge 1 commit intovjeantet:masterfrom
A0150315:fix/memory-leak-dismissal-polling
Open

fix: memory leak in dismissal polling due to undrained autoreleasepool#65
A0150315 wants to merge 1 commit intovjeantet:masterfrom
A0150315:fix/memory-leak-dismissal-polling

Conversation

@A0150315
Copy link
Copy Markdown

@A0150315 A0150315 commented Mar 6, 2026

deliveredNotifications returns new NSArray+NSUserNotification copies on each call. On the GCD background thread used by startDismissalPolling, there is no RunLoop to automatically drain the autorelease pool, causing continuous memory growth (~5 calls/sec) while the notification is idle.

Changes:

  • Wrap polling loop body in autoreleasepool to drain ObjC temporaries
  • Add pollingCancelled flag for clean cancellation
  • Use NSLock in outputAndExit to prevent race conditions between polling thread, timeout handler, and user activation callback

deliveredNotifications returns new NSArray+NSUserNotification copies on
each call. On the GCD background thread used by startDismissalPolling,
there is no RunLoop to automatically drain the autorelease pool, causing
continuous memory growth (~5 calls/sec) while the notification is idle.

Changes:
- Wrap polling loop body in autoreleasepool to drain ObjC temporaries
- Add pollingCancelled flag for clean cancellation
- Use NSLock in outputAndExit to prevent race conditions between
  polling thread, timeout handler, and user activation callback
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.

2 participants