Skip to content

Instantly share code, notes, and snippets.

@julienXX
Last active May 1, 2017 16:21
Show Gist options
  • Save julienXX/bb076b0b95c738217b03e14e51f23876 to your computer and use it in GitHub Desktop.
Save julienXX/bb076b0b95c738217b03e14e51f23876 to your computer and use it in GitHub Desktop.
//Tried something a bit brutal like to isolate the leak:
...
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
__block BOOL notificationStillPresent;
NSUInteger notificationsCount = [[NSUserNotificationCenter defaultUserNotificationCenter] deliveredNotifications].count;
do {
notificationStillPresent = NO;
NSUInteger currentCount = [[NSUserNotificationCenter defaultUserNotificationCenter] deliveredNotifications].count;
NSLog(@"initial count %lu", (unsigned long)notificationsCount);
NSLog(@"current count %lu", (unsigned long)currentCount);
if ((unsigned long)currentCount == (unsigned long)notificationsCount) notificationStillPresent = YES;
if (notificationStillPresent) [NSThread sleepForTimeInterval:0.20f];
} while (notificationStillPresent);
dispatch_async(dispatch_get_main_queue(), ^{
NSDictionary *udict = @{@"activationType" : @"closed", @"activationValue" : userNotification.otherButtonTitle};
[self Quit:udict notification:userNotification];
exit(0);
});
});
...
//This code is wrong as it closes all notifications but I wanted to try and it's still leaking.
@julienXX
Copy link
Author

julienXX commented May 1, 2017

If I increase the sleeping time, leaking is mitigated but that's not a proper way to fix it.

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