Call for beta tests We are looking for developers to test their applications with a different set of semantics for Dispose() on NSObjects and provide us with feedback and let us know if this breaks their existing applications.
The semantics for MonoTouch’s Dispose on NSObject and their subclasses as of MonoTouch 6.0.6 (the current stable release) are as follows: - Release the native reference - Clear the handle of the object - Clear any managed fields that cache or point to other managed objects - Break the Unmanaged->Managed link This means that when you call Dispose, you have effectively registered your lack of interest in the object. The above is problematic in some conditions, for instance, when the unmanaged world keeps a reference to the managed object that has been Disposed and a method is invoked on it. Typically users will see an error message like this: Selector invoked from objective-c on a managed object of type MyApp.MyType (0x10D27C50) that has been GC'ed However the above is not always true. The managed object could still be alive, but the linkage between the two worlds has been broken and when MonoTouch tries to find the managed object for a particular native object it won't find it and throws this exception. Sadly, calling Dispose() actively is a common pattern, so we are experimenting with some new semantics for Dispose that would eliminate the above problem for the conditions outlined before. We have implemented a new approach for Dispose in MonoTouch 6.0.7 (currently available in the Beta channel). In this beta, Dispose() instead performs these steps: - Release the native reference - Handle and backing fields are preserved unless this was the last reference to the object. This means that a managed NSObject subclass that is being referenced by unmanaged code is kept intact and fully operational after a call to Dispose. The managed object will be kept alive for as long as the unmanaged code references the object. This has the potential downside that some objects that would have previously been eligible for collection will not be, until a later point in time. But the advantage is that the managed hierarchy more closely mimics the behavior of the unmanaged one. *How to install* Enable the beta channel in MonoDevelop's update preferences, and you'll be offered this beta (it's MonoTouch 6.0.7). If you find any bugs that blocks you, it is possible to downgrade to a previous release by downloading it from your Xamarin Store account (https://store.xamarin.com/Account/Products) and install it over this beta. Feedback We're interested in any kind of feedback, either positive (it works just like it used to / it works a lot better than it used to) or negative (it crashes / even more inexplicable exceptions are thrown), even if you don't think this applies to your apps. Thanks, Rolf
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
