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 13455 [details]
Dispose(true) is not called when a controller is popped from a UINavigationController (pressing back button).
**Steps to Reproduce:**
1. Run the attached sample on an iOS device.
2. Press the Next View button to show the SecondViewController
3. Press the Back button
4. Repeat 2-3
Dispose(false) is called, and you will see the log messages (in Debug mode) indicating that.
Dispose(true) is not called on SecondViewController when the Back button is pressed.
Expecting Dispose(true) to be called at some point when Back is pressed because SecondViewController is not needed anymore.
**Build Date & Platform:**
=== Xamarin Studio ===
Version 5.9.7 (build 22)
Installation UUID: e01c3049-a2d2-4e0a-aad8-afe6fb627c4d
Mono 4.0.4 ((detached/d481017)
GTK+ 2.24.23 (Raleigh theme)
Package version: 400040004
=== Xamarin.Android ===
Version: 220.127.116.11 (Business Edition)
Android SDK: /Users/johnmiller/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
=== Xamarin Android Player ===
Version: Unknown version
Location: /Applications/Xamarin Android Player.app
=== Apple Developer Tools ===
Xcode 7.0 (8227)
=== Xamarin.iOS ===
Version: 18.104.22.168 (Business Edition)
Build date: 2015-09-25 18:08:44-0400
=== Xamarin.Mac ===
Version: 22.214.171.124 (Business Edition)
=== Build Information ===
Release ID: 509070022
Git revision: 6bd1f169df44ca96addf8a035316c535a4fa46fa
Build date: 2015-09-30 12:30:15-04
Xamarin addins: 1c3e5c0859bdfec0ecd481a57ad6c03bc22f5536
=== Operating System ===
Mac OS X 10.10.5
Looking for an explanation of how this is designed to work, and if the Expected results are reasonable or misunderstood.
The behavior is as expected.
Dispose is called when the object is garbage collected, which only happens the the garbage collector is executed. You can confirm this by manually calling GC.Collect, and Dispose will be called soon after.
In the simulator Xamarin.iOS will force a garbage collection frequently to catch a certain type of programming errors faster (it's better that bugs show up when the developer debugs in the simulator than when the user runs the app on his device) - this is why Dispose only seems to be called in the simulatur (it will be called on device too, but only when the garbage collector decides to collect, which may take a while).
Also Xamarin.iOS will never call Dispose directly, it's called from the finalizer, which means 'disposing' will always be false (if you call Dispose directly yourself, you'll get 'disposing = true').