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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dantz
    New Member
    • Oct 2008
    • 71

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

    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<stri ng, 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.

    TIA

    -dantz
  • dantz
    New Member
    • Oct 2008
    • 71

    #2
    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

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      Originally posted by dantz
      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

      Without loading/playing the animation image: 220MB
      With loading/playing the animation image : 1.3GB
      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.

      Comment

      • dantz
        New Member
        • Oct 2008
        • 71

        #4
        Originally posted by tlhintoq
        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.
        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.

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          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.
          http://www.libpng.org/pub/png/pngintro.html
          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.

          Comment

          • dantz
            New Member
            • Oct 2008
            • 71

            #6
            oh...ic..
            now I know.

            Thanks for sharing the info.

            I learned something there.

            :-)

            Comment

            • sword117
              New Member
              • Jun 2010
              • 35

              #7
              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? =)

              Comment

              Working...