Not to interject to much into this conversation, but I am fearful of calling GC.Collect() automatically too much. For example, I find the magnetic field sensor to basically take over my htc evo when I am getting change events. I realize that you aren't talking about called a .Collect() on every change event. My concern is that something that fires so often, adding the .Collect will just result in even worse performance. Granted, I am not privy to the source and have other things to do if I was, so take what I have said for what it is worth. Maybe this is a good time for Xamarin to explain the intricacies of the Mono for Android GC?
Wally > From: j...@xamarin.com > Date: Fri, 3 Feb 2012 10:00:22 -0500 > To: monodroid@lists.ximian.com > Subject: Re: [mono-android] Excessive JNI global references (2001) on hardware > > On Feb 3, 2012, at 7:54 AM, PVoLan wrote: > > Please, look at this test case https://github.com/PVoLan/TestAccelerometer > > Your sample is is largely a simplified version of: > > http://bugzilla.xamarin.com/show_bug.cgi?id=1084 > > The current "fix" (workaround) is to dispose of `val` within > SensorListener.OnSensorChanged(): > > public void OnSensorChanged (SensorEvent e) > { > var val = e.Values; > try { > Android.Util.Log.Info("-------------","Works for: " + > (DateTime.Now - created)); > Android.Util.Log.Info("-------------",string.Format("X: > {0} Y: {1} Z: {2}", val[0], val[1], val[2] )); > } finally { > ((IDisposable) val).Dispose (); > } > } > > A future release will improve matters by automatically calling GC.Collect() > when we pass a certain gref threshold, but even that fix may not be ideal as > it may result in too many collections (e.g. if you have an animation loop, > you want to control when the GC runs), so explicitly disposing of wrappers > may still be required even after the implicit GC.Collect() call is in place. > > - Jon > > _______________________________________________ > Monodroid mailing list > Monodroid@lists.ximian.com > > UNSUBSCRIBE INFORMATION: > http://lists.ximian.com/mailman/listinfo/monodroid
_______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid