[mono-android] Larger memory footprint when using BitmapFactory.DecodeFile in C# (and huge memory for tiny image)
Matthew Leibowitz
mattleibowmail at gmail.com
Mon Jun 18 11:15:12 UTC 2012
Here is the image that I am using - if anyone wants to see it...
On Mon, Jun 18, 2012 at 1:05 PM, Matthew Leibowitz <mattleibowmail at gmail.com
> wrote:
> Hi all,
>
>
> I just want to see if anyone else has noticed that when loading images
> into memory, the exact same C# code uses more memory to hold the images
> (~1.5x the amount in Java).
>
> This Java code results in a total memory size of *105.5 MB*:
>
> Bitmap[] bitmaps = new Bitmap[100];
>
> for (int i = 0; i < 100; i++)
> {
> String root =
> Environment.getExternalStorageDirectory().getAbsolutePath();
> String imagePath = "/evolution/threesixty/216/Edaphosaurus_001.jpg";
>
> bitmaps[i] = BitmapFactory.decodeFile(root + imagePath);
> }
>
> This C# code results in *148.1 MB*:
>
> Bitmap[] bitmaps = new Bitmap[100];
> for (int i = 0; i < 100; i++)
> {
> string root = Environment.ExternalStorageDirectory.AbsolutePath;
> string imagePath = "/evolution/threesixty/216/Edaphosaurus_001.jpg";
>
> bitmaps[i] = BitmapFactory.DecodeFile(root + imagePath);
> }
>
> Does anyone have any ideas as to why? I understand that the .NET wrappers
> may use a little more to hold extra binding data or things, but surely not
> that much?
>
> Also, as a side question:
> Each image is only *60 KB** *on disk, why is the in-memory version *1 MB*?
> I know that my loading method does not do any sampling/density checking,
> but that was not the aim. Surely loading a <100KB image should not exceed
> 100KB memory space?
>
>
> Regards,
> Matthew
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodroid/attachments/20120618/55c4f624/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Edaphosaurus_001.jpg
Type: image/jpeg
Size: 62316 bytes
Desc: not available
URL: <http://lists.ximian.com/pipermail/monodroid/attachments/20120618/55c4f624/attachment-0001.jpg>
More information about the Monodroid
mailing list