Re: Cycling between images increases memory usage

From: Scytrax (anonymous_at_discussions.microsoft.com)
Date: 05/09/04


Date: Sun, 9 May 2004 04:01:05 -0700

Hi Bob.

I read your faq recently and realized the importance of disposing images. That handled another problem I was having in the same application. Thanks.

However, when cycling images in the picture box, I cannot dispose of the image because I keep looping through the images and so I need all images to be displayed more than once.

I do something like the following (pseudo code):

int counter = 0;
Image images[] = new Image[5];
images[0] = Image.FromFile("image1");
images[1] = Image.FromFile("image1");
images[2] = Image.FromFile("image1");
images[3] = Image.FromFile("image1");
images[4] = Image.FromFile("image1");
this.Timer1.Start();

onTimerTick:

this.PictureBox1.Image = this.images[counter++];
if(counter == this.images.Length)counter = 0;

In theory, this should not cause any memory problems, right?

I have been testing my program again during the night and after running app. 6 hours, I only had an increase of about 200K. So maybe I don't have a problem anymore. However, I would still like a confirmation that the general procedure as described above should not cause any memory problems.

Thanks for being a great help to your fellow coders, Bob!

Anders



Relevant Pages

  • Re: Color Image Formation
    ... I think I have a better understanding of the importance of the reflection of the light. ... In the particular application I'm interested in (satellite images), I'm still not convinced this occurs a lot. ... (u1 corresponds to the red channel, and u2 corresponds to the green ... Snow is white. ...
    (sci.image.processing)
  • Re: Can I set a different style for or ?
    ... You can refer to the text as text in CSS rules in certain ways but you cannot describe its rendering in CSS, since there need not be any default rendering for it and if there is, it cannot be referred to in CSS. ... alt attributes have been described as helping blind people who do not see images. ... In those cases, I usually don't let the images download at all, I do see their ALT texts though, and the ALT text lets me clearly see what images are of importance to the job at hand, and which aren't. ...
    (comp.infosystems.www.authoring.stylesheets)
  • Re: Subject and composition
    ... lists, here's mine. ... In order of importance (which is of course a ... personal thing), and for most images: ... Whenever I'm stuck for a good image, I try to remind myself of those 3. ...
    (rec.photo.equipment.35mm)
  • Re: spotting scope question-specific
    ... produce better images than a smaller properly designed F5 lens. ... Stopping down the larger lens can produce a better image. ... importance of focal ratio/focal length is critical here. ... but I have to trust his knowledge. ...
    (rec.birds)

Loading