Bug 54940 - Memory leak on simple Activity
Summary: Memory leak on simple Activity
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 7.2 (15.1)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2017-04-10 12:07 UTC by Luigi Maestrelli
Modified: 2017-04-10 21:25 UTC (History)
2 users (show)

Tags: 15.1R
Is this bug a regression?: ---
Last known good build:

Sample app on Xamarin.Android and Android Studio (1.37 MB, application/x-rar)
2017-04-10 12:07 UTC, Luigi Maestrelli

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description Luigi Maestrelli 2017-04-10 12:07:26 UTC
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
Android Studio 2.3.1
Comment 1 Jon Douglas [MSFT] 2017-04-10 21:25:20 UTC
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.