[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:05:43 UTC 2012
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/ec97f0f2/attachment-0001.html>
More information about the Monodroid
mailing list