[mono-android] debugger constantly detaches
Jonathan Pryor
jonp at xamarin.com
Thu Jun 14 15:35:10 UTC 2012
On Jun 13, 2012, at 9:30 AM, Sayed Arian Kooshesh wrote:
> this is an idea but since I don't know your design, I don't know if it will fit.
>
>
> make a
>
> [Application]
> public class myGlApp: Application
> {
>
> public void onCreate()
> {
> //create a pool of float bytes here that you can reuse
>
> }
>
> ~myGlApp()
> {
> //MAKE SURE TO DESTROY POOL PROPERLY
> }
I doubt that this will work, as I doubt that the myGIApp finalizer will ever be invoked. The Application instance is a singleton that is alive for as long as the process lives, and when Android exits the process Android doesn't give the GC a chance to run (why should it?), and even if it did give the Dalvik GC a chance to run it's highly unlikely that Mono's GC would get a chance to run, and if Mono's GC doesn't run (AND find that Dalvik is no longer referencing the Java-side Application instance!), then Mono's GC won't execute the finalizer.
In short, I think it's a safe bet that the Application finalizer will never run, period.
Finally, as a point of style, you should never provide a finalizer for Java.Lang.Object subclasses. You should instead override Java.Lang.Object.Dispose(bool):
http://androidapi.xamarin.com/index.aspx?link=M:Java.Lang.Object.Dispose(System.Boolean)
- Jon
More information about the Monodroid
mailing list