Bug 25709 - Memory leak on bound Source of an Image
Summary: Memory leak on bound Source of an Image
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.3.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-01-05 05:32 UTC by thomas.cadiou
Modified: 2016-04-08 18:42 UTC (History)
6 users (show)

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

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 thomas.cadiou 2015-01-05 05:32:03 UTC
I am currently testing on a Sony SGP511 running Android 4.4.2. I am using Xamarin.Forms

I am using a view bound to a ViewModel. In this view I have an image declared that way
<Image Source="{Binding SelectedImagePath}" />
With the SelectedImagePath property pointing to various jpg images on the sdcard of the tablet.
I have buttons to switch between 5 different images (changing the SelectedImagePath value).

If I click like ten times in a row, the application crashes with an out of memory exception, the heap exceeding 200MB.
If I switch between two sources repeatedly (going from A to B to A to B, etc.) the heap grows at each step by like 5MB, indicating that the image bitmap for each source is leaked and never recycled.

This issue wasn't present with the previous version I used (
Comment 1 thomas.cadiou 2015-01-05 05:50:36 UTC
Actually the issue is the same if I remove the image from the layout and create a new one with the same or a different path as its Source, instead of just changing the source via binding.
The bitmaps still seem to get leaked and I get the same application kill when it reaches 200MB of heap.
Comment 2 Seth Rosetter 2015-05-18 19:01:17 UTC
Thank you for taking the time to submit the bug. Going forward, we're asking customers to attach reduced reproductions to the bugs. Ideally the reproduction would be created by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue. We know not everyone has time to do this and it's not a requirement to submit a bug but it does help us resolve issues faster as well as ensuring we're solving the same issue you're seeing so we very much appreciate it.  

Warm regards,
Xamarin Forms Team
Comment 3 Paul DiPietro [MSFT] 2016-04-08 18:42:56 UTC
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.

For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team