Performance (CPU, RAM usage)

Apr 25, 2010 at 10:24 PM

I load 30 images with average size 3200 * 2000 pixels. Combine (all 30) images disk size is 90MB.


Image image;
Decoders.AddDecoder<JpegDecoder>(); foreach (FileInfo info in aEvent.Files) { image = new Image(); image.SetSource(image.Load(info.OpenRead()); }

I use fImage.IsLoadingSynchronously = false; and it takes a little longer then 2 minutes to finish foreach. It also "eat" more then 1 GB RAM.

I have 4GB RAM and Intel Quad with 2.44GHz for each core.

Is it normal that loading is so slow and so memory consuming?

 

Coordinator
Apr 25, 2010 at 10:39 PM
Remember that the images will be stored as raw images in the memory to
render them and they are stored with compression on your hard disk.

Each pixel has a red, green, blue and alpha channel, which means 4
bytes. So one of your images has about 24 MB in the Memory and when you
hold all images in the ram it means it are about 720 MB just for the
images. Plus the memory that will be consumed by the browser, the
silverlight plugin and all other stuff.

So the answer is yes: This is normal.

The question is, how to optimize it. The problem is, that it is not C++,
you can free the memory, so my suggestion is to ensure, that the scope
of each image is very small. I hope combining doesnt mean having an
image with dimension of about 20000 * 30000 pixels or something like
this. Use Deep Zoom for this. Do not hold any references to the image
you dont need. DONT store a list of all images. Then perhaps the GC will
release your memory and something like this happens:

(1) Startup (RAM acquired: 60 MB)
(2) Image #1 loaded, set to current (90 MB)
(3) Image #2 loaded and merged with Image #1 (130 MB)
(4) Image #3 loaded and merged with Image #1 (150 MB)
(5) Image #2 and #3 Release by GC (90 MB)
(6) Image #4 loaded and merged with Image #1 (120 MB)
(7) Image #5 loaded and merged with Image #1 (150 MB)
(8) Image #6 loaded and merged with Image #1 (180MB)
(9) Image #4, #5 and #6 Release by GC (90 MB)

to be continued...

Hope this helps
Apr 26, 2010 at 5:44 AM
Edited Apr 26, 2010 at 5:45 AM

Great, i just want to ask. I don't know anything about compression and so on. I will rethink what to do, i just wanted to be sure that this is normal.

What about loading time?

And combining doesn't mean combine images, just open them one by one.

Coordinator
Apr 26, 2010 at 6:25 AM
Yes, loading time is also normal. This is the problem with the managed
stuff, where you dont have such a good control about memory. Therefore
the silverlight core is written in an unmanaged language like C++.

Afaik the JPG loader is a little bit faster then PNG, but I have never
made some tests.
Apr 26, 2010 at 7:38 AM

I am using JPG.
Never mind. Just want to be sure.

Great library by the way.