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 10151 [details]
Changing the BackgroundColor of a Button many times results in an OutOfMemory exception on Android
**Steps to Reproduce:**
1. Run the attached sample on an Android Device
2. Toggle back and forth by touch the View A and View B buttons at the bottom
3. Repeat step 2 ~100 times
An OutOfMemory exception occurs.
**Build Date & Platform:**
Moto G Android 4.4 API 19
While we're waiting for further testing on other devices, if the original customer can still reliably reproduce this problem on a Moto G Android 4.4. API 19, it might be worth trying a quick (if "indelicate") test: add a `GC.Collect(); GC.WaitForPendingFinalizers();` to the event handler for `buttonViewA.Clicked` or `buttonViewB.Clicked`, or both.
In my quick initial tests (following the steps on  on the Xamarin Android Player (API 19)), I saw:
(a) When I added `GC.Collect(); GC.WaitForPendingFinalizers();` to both of the `Clicked` event handlers and then tapped 400 times: the heap size plateaued around 400,000, and the managed object counts plateaued around 7200 after about 150 button taps. In this experiment, the only object type that changed counts after the third button click was `System.WeakReference`.
(b) When I tapped 400 times and then explicitly called `GC.Collect()` to log the current heap: the heap size reached 2,624,704, and the managed object count reached 65149. The most numerous and most space-consuming object type on the heap was `System.WeakReference`.
>  http://stackoverflow.com/questions/19125266/how-to-take-heap-snapshot-of-xamarin-androids-mono-vm/19126051#19126051
Xamarin Customer Support
Fixed in master