By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,006 Members | 541 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,006 IT Pros & Developers. It's quick & easy.

C#-App: High Memory Usage in Animation of image files using timer

P: 71
HI everyone,

I hope someone can help me on this.
I have form application that has 3 Timers that does an animation (changing an image for every interval)

Each image are loaded at start of application and saved into a Dictionary<string, List<Image>>

The dictionary will have 5 items which is for 5 controls.
then each control will have this images in the dictionary(I also assigned the timers):

Timer 1 (Interval:100) = 110kb / image, 25 images, 425x165
Timer 2 (Interval: 25) = 72kb / image, 81 images, 615x810
Timer 3 (Interval: 50) = 10kb / image, 25 images, 249x169

Then 3 timers will be doing the animation for those 3 Dictionary.

Currently I will just use my task manager to read the memory usage of my application.

Without loading/playing the animation image: 220MB
With loading/playing the animation image : 1.3GB

NOTE: I have found out about CLRProfiler.exe but I may need some time to study how it is used and how to benefit from it and i am also having trouble showing the data when my application run.So just used task manager as of the moment.

Hoping for your positive replies.


Sep 16 '09 #1
Share this Question
Share on Google+
6 Replies

P: 71
hmmm..I think I found my answer to my question. Seems like it is more efficient to load the file whenever they are needed rather than loading them all at start.

If I do this procedure I am having a constant usage of 580mb.

But I am still investigating on this matter.

If anyone have comments please post it still.

Thanks a lot
Sep 16 '09 #2

Expert 2.5K+
P: 3,525
I don't know where you are getting those image sizes from. Common sense says that if an image of 425x165 is 110k, then a bigger image of 615x810 isn't going to be a smaller size of 72k.

425x165 @ 8 bit color = 205 kb x 25image = 5125 k = 5 meg
615x810 @ 8 bit color = 1.43 meg x 81 images = 11583 meg
249x169 @ 8 bit color = 123.3 kb x 25 images = 30825 k = 30 meg
Yep - sounds about like 1.3 gig

Keep in mind that jpg (compressed) file size on disc is not the same as uncompressed memory consumption once you load them into memory.
Sep 16 '09 #3

P: 71
Thanks tlhintoq.
I really appreciate your reply.

I forgot to tell that these are PNG files. Im not sure if there are any difference in your computation.

The 615x810 images contains less color and drawing compared with the 425x165 images. I think that is the reason why it has a smaller size.
Sep 17 '09 #4

Expert 2.5K+
P: 3,525
My computation was simply by creating a new document in Photoshop of RGB at 8 bit. Each time you enter new dimensions it tells you the size of the document.

The PNG file format still employees compress when saving. A very good compression scheme.
So that is why the files are smaller on hard drive.

But once you load them into memory they become bitmaps, meaning no compression. So your 615x810 image is still 810 rows of 615 8-bit pixels. That's where all your memory is going.
Sep 17 '09 #5

P: 71
now I know.

Thanks for sharing the info.

I learned something there.

Sep 17 '09 #6

P: 35
i got the same problem too.. but im loading 2003 jpg images, and it reads 3.279.108k on task manager.. if i use a background worker would it load faster? =)
Jul 23 '10 #7

Post your reply

Sign in to post your reply or Sign up for a free account.