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.
Created attachment 25 [details]
Sample project illustrating the bug.
I asked this same question in StackOverflow but I have a hunch that this is a bug in the MonoTouch runtime. See here for the question. It pretty much explains everything.
But in short, my view controller and all it's subviews are not being garbage collected unless I remove my custom UIButton from the view. If you comment out line 66 in MyViewController.cs you'll see that none of the finalizers will be called when you perform the following test.
1. Compile and run the attached proj in the simulator
2. Touch the button "Push a new controller"
3. Go back in the nav controller (popping a view controller off the stack)
4. Verify that the finalizers are being run by seeing console writes
Note: running on the device, you'll have to touch the "Collect Garbage" button before the objects will be finalized which is fine since I'm not supposed to know when garbage collection occurs anyway. But commenting out line 66 causes all of my objects to not be candidates for GC.
Also, notice that none of the other subviews need to be removed. Lines 65 and 67 are commented out and it works just fine.
This is a duplicate of #57; Fix will be on the next release, and the stackoverflow post has a workaround
*** This bug has been marked as a duplicate of bug 57 ***