Bug 55425 - Images Take Up 20x More Memory Than They Should
Summary: Images Take Up 20x More Memory Than They Should
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-04-20 13:24 UTC by Hakan
Modified: 2017-04-23 12:30 UTC (History)
1 user (show)

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

Test Image (1.70 KB, image/png)
2017-04-20 13:24 UTC, Hakan

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 Hakan 2017-04-20 13:24:36 UTC
Created attachment 21660 [details]
Test Image

A 700x461 pixel argb png should take up 4*700*461 bytes which is roughly 1.23 MB when converted to bitmap. When it is placed inside an Image element which has a smaller size, it should even occupy less space in memory due to sampling.

But when I investigate the app using Android Monitor-->Memory, I see that for every time I add this image, it increases memory by about 20 MB.

I tested with many different images but the result is the same and it cause out of memory exceptions rather quickly. I attached one of the images I used for testing.

Could you please test this as soon as possible because if it is the case, it is a very very urgent bug.

Here is the simple xaml that can be used to reproduce this:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
    <StackLayout Padding="0,700,0,100" Spacing="20">

            <Image WidthRequest="160" Source="withoutalpha.png"></Image>

Comment 1 Hakan 2017-04-23 12:30:59 UTC
I found out that it is due to the image file being in the drawable folder. No problem when image is in the resource folder with the right screen resolution. Marking it as resolved.