Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 21395 [details]
Sample app on Xamarin.Android and Android Studio
I created a simple activity with a button to navigate to another activity, when I pressed the back button the second activity is not been cleaned and the memory usage keeps rising every time I clicked on the button.
To test if the problem was some thing on my layout I created a native app (Java) using the same layout, drawable and styles. On this app, every time that I press the back button the memory usage drops.
I was able to notice that using Android DDMS and watching the allocated memory.
I'm using Visual Studio 2017
Xamarin.Android SDK 188.8.131.52
Android Studio 2.3.1
I believe you are referring to the count of allocations of the second activity. i.e. something like this:
There is a note on the garbage collection documentation: https://developer.xamarin.com/guides/android/advanced_topics/garbage_collection/
This is not a reference counting system; objects will not be collected as soon as there are no outstanding references, or when a scope has exited. The GC will run when the minor heap has run out of memory for new allocations. If there are no allocations, it will not run.
You can view more about this algorithm here:
Please note that there might be some fundamental differences between Mono's GC and ART's GC. You can read more about ART's GC here:
I am marking this bug as RESOLVED | ANSWERED for the time being.