Surfing between activities -> memory usage increase

Hi. Let this be my first post on this forum.

I'm currently developing android app with Xamarin studio. I'm quite a familiar on deving with Java Android but deving with C# on android is pretty new to me.

I currently ran into problems with switching between activities. I have implemented Gesture listener to my app, but when I switch for example from MainActivity to SecondActivity RAM memory of phone increases. And when I surf multiple times between those activities my back button throws me to previous Activity. That's why it might took quite a much back button presses to quit the program.

What I'm doing wrong and how should I tweak my code. I'll post small example from my testcode (which is similar to android tutorials).

    public bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)

        {
            if (distanceX > 0.00) 

            {
                var second = new Intent(this, typeof(SecondActivity));

                StartActivity(second);



                //StartActivity(typeof(SecondActivity));

                return true;

            }

            else

            {

                return false;

            }   

        }

And SecondActivity:

    public bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)

        {
            if (distanceX < 0.00) 

            {
                var main = new Intent(this, typeof(MainActivity));

                StartActivity(main);



                //StartActivity(typeof(MainActivity));

                return true;

            }

            else

            {

                return false;

            }   

        }

Thank you in advance for any help you can provide.

Posts

  • MikaKorhonenMikaKorhonen FIMember

    Well, I did got no answer. Maybe my problem was too common sense or described badly.

    I ran some tests. Seems like system knows how to fflush unused RAM. So if someone ever ran into these kind of problems, I hope this post would help abit.

  • FZelleFZelle DEMember ✭✭✭

    Well, I did got no answer. Maybe my problem was too common sense or described badly.

    Yes too common sense, aka basics of dotnet.
    .NET and therefor Xamarin.Android uses a Garbage Collector that does exactly that.

Sign In or Register to comment.