Swift 3 - Notification leaks
Swift 3 - Notification leaks
- Subject: Swift 3 - Notification leaks
- From: Andreas Mayer <email@hidden>
- Date: Sat, 18 Jun 2016 13:21:43 +0200
I have just migrated a project to Swift 3 which worked surprisingly well for the number of changes necessary.
After checking out the new memory graph (cool!) I noticed that I am leaking notifications. Example:
NSConcreteNotification 0x102c28600 {name = NSApplicationDidBecomeActiveNotification; object = <NSApplication: 0x100e15080>}
The really bad thing is, some were keeping old windows in memory!
After changing back to NSNotification where possible, all is well again.
Leaking:
func windowDidBecomeKey(_ notification: Notification) {
Working:
func windowDidBecomeKey(_ notification: NSNotification) {
Block based observers do still leak though.
This is what it looks like:
http://www.harmless.de/images/other/Notification-Leak.png
(Is there a way to get a textual representation of that graph?)
And here the backtrace:
http://www.harmless.de/images/other/Notification-Leak-Backtrace.png
Just below that is my window's init call.
(I couldn't figure out how to copy the backtrace either.)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden