How are you measuring the memory usage?  Could you be including the Mono
run time in the C# calculation?

The images you are loading are jpg compressed.  Bitmap is an uncompressed
format.  A little Googling showed a typical JPEG compression ratio of 10:1
to 20:1 without losing noticeable image quality.  60KB -> 1 MB is in that
range.

Darren
On Jun 18, 2012 6:06 AM, "Matthew Leibowitz" <mattleibowm...@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
>
> _______________________________________________
> Monodroid mailing list
> Monodroid@lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to