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?
Here is the image I am using (994x748px @ 300dpi):

Based on replies from the Mono for Android mailing list:
And another:
After looking at this information on compression (I have no idea what went on in my head as I realize that compression makes the in-memory image smaller for saving and loading it will then decompress it into memory), I now understand how things work 😉
The image is decompressed to almost 2MB when saved as a bitmap – and if I look at the image properties in Irfanview.
So what I am doing now is setting the sample size to
2and using theBitmap.Config.Rgb565. This reduces the total images size to about 30 MB, which is way better. Although the quality is not as good, I can then load the higher resolution image when I need it and the user doesn’t know.