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 for Bug 56052 on
Developer Community or GitHub if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Created attachment 21982 [details]
According to Xamarin Profiler, Android Activities are not being garbage collected when device is rotated multiple times.
I am using Xamarin Profiler on a simple sample project that has a call to `GC.Collect()` in the main Activity's `OnCreate` method. After rotating the device multiple times, inspecting a snapshot reveals more than one instance of the Activity is marked as 'Live' in the Profiler. I assume 'Live' means that the object is unable to be garbage collected.
I can observe this whether or not the "Don't Keep Activities" setting in the Android developer options is enabled.
* Xamarin Profiler 1.4.0-1
* Xamarin Studio 6.3
* Xamarin.Android 18.104.22.168 (VS Enterprise)
* macOS 10.12.4
* Android Emulator with Nexus 5 configuration running Android 7.1.1
Maybe I am not understanding the intended behavior, but from what I understand about how the Mono VM GC works on Android, these Activities should be destroyed by the call to `GC.Collect()` or even the snapshot feature in the profiler.
Created attachment 23227 [details]
Profiler at beginning of session
Created attachment 23228 [details]
Profiler after 7 rotation cycles
Confirmed via Visual Studio 2017 Enterprise and Xamarin.Android 22.214.171.124 on Windows.
The before.png screenshot shows the beginning of the profiler session. Note that Andleaks.MainActivity count is 1. After 7 rotation cycles (Nexus 5), the Andleaks.MainActivity count goes to 15 (see after.png).