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.
Insert your Google Maps API Key in manifest and run the attached project (it requires Android 4.2 or higher). Change device orientation by rotating it. The activity will get recreated each time orientation change and so will memory leak increase (looking at Heap's allocation through DDMS)
I am using Google Play Services (JellyBean) 16.0, Xamarin 4.12.4. The application really doesn't do anything, just inflates the view where map fragment is defined.
Tested on Genymotion emulator, Galaxy Nexus 7 2013.
protected override void OnCreate(Bundle bundle)
Created attachment 6795 [details]
Project withough Google Play Services component (otherwise it is too big)
I suspect the problem is that the GC needs to be run. Mono's GC gets a skewed view of the world, because each Java.Lang.Object instance is only ~20 bytes in size, no matter how much Java memory it may be holding onto:
Since Mono GC's are "on-demand", this means that a great deal of Java-side garbage can collect before Mono's GC will kick in, because it's invisible.
In such scenarios, you may need to help things out, by e.g. overriding Activity.OnDestroy() and calling GC.Collect().
Does that reduce your memory use?
Yep, makes total sense. And indeed, quick test shows that it seems to be the cause. Arrgh, I should have thought of that :)
I'll do more tests tomorrow. Thanks!
Looks that's was it. GC.Collect() FTW.