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.
The snipped below shows the problem. I only tested this under Android. Basically the a long WeakReference "theReference" to the ImageCircleRenderer should have a valid target when the ImageCircleRenderer's finalizer is called. However, the theReference.Target is nulled when the CircleImage finalizer is called. It appears that XF/mono is breaking the weakreference. This happens ONLY with custom render objects, so this is something specific to custom renderers.
[assembly: Xamarin.Forms.ExportRenderer(typeof(TDSP.Controls.CircleImage), typeof(TDSP.Controls.Droid.ImageCircleRenderer))]
public class ImageCircleRenderer : ImageRenderer
// When we get here, theReference.Target is null, but it should not be since this is a long
// WeakReference and this object finalizer did not finish executing.
public class CircleImage : Image
public CircleImage ()
WeakReference theReference = WeakReference(ImageCircleRenderer_instance, true);
Can you override Dispose and don't call base to see if fixes the issue?
adding this to the ImageCircleRenderer does not make any difference:
protected override void Dispose(bool disposing)
I also found that ~ImageCircleRenderer() is not called at all for 33 out of 44 instances, yet the Xamarin Profiler shows that no instances are leaked. So it seems that the Finalizer is skipped altogether in many cases, which definitely look like a XF bug. I am guessing finalization is suppressed somewhere?
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
Here are some reproduction best practices: https://gist.github.com/jassmith/92405c300e54a01dcc6d