I have a problem where my application seems to lose GREF's very quickly.  I
tracked it down to the Sensor handler.  Basically after running for about an
20 minutes my application becomes unresponsive (very slow) and produces and
ANR dialog.  

The problem seems to be in my Sensor Handler, but for the life of me I don't
know what is wrong.  I have boiled it down to simply reading the X,Y,Z data.  

If I do that, a GREF gets lost and eventually, (within 15-20 minutes) I hit
the 46800 maximum GREF count which causes a full GC pass which frees some
up, then it hits the max again fairly quickly, and the process repeats. This
is causing the app to run VERY slow.

The code is very simple:

in OnResume():
            SensorManager sm =
(SensorManager)GetSystemService(SensorService);
            if (sm != null)
            {
                sm.RegisterListener(this,
sm.GetDefaultSensor(SensorType.Accelerometer), SensorDelay.Game);
            }

in OnPause():
            SensorManager sm =
(SensorManager)GetSystemService(SensorService);
            if (sm != null)
            {
                sm.UnregisterListener(this);
            }

and the handler:
        public void OnSensorChanged(SensorEvent sensorEvent)
        {
           // If I don't do the following three lines, GREF counts don't go
haywire
            float X = sensorEvent.Values[0];
            float Y = sensorEvent.Values[1];
            float Z = sensorEvent.Values[2];
            // sensorEvent.Dispose(); //Dispose does not seem to help
        }

Am I forgetting/missing something?  It seems pretty simple.

-Mike





--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Sensor-Handler-loses-GREF-handles-tp5711686.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to