Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
If an NSObject is added to more than one notification list in NSNotificationCenter.DefaultCenter, it must call RemoveObserver once for each AddObserver call to be properly disposed of. The first time RemoveObserver is called, it is removed from every notification list, but isn't garbage collected until RemoveObserver is called the same number of times AddObserver is called.
Attached is an example project I used to test this behavior.
Created attachment 1850 [details]
Test for Add and RemoveObserver
Fixed in monotouch master (1e5630d), unit tests included. The next release with this fix will be 5.3.4.
For now you can just use the workaround you found yourself (call RemoveObserver multiple times).
Thanks for the perfect test case!