ImageList is using up memory

  • Thread starter Thread starter copyco
  • Start date Start date
C

copyco

I've got an application where I have an animated image in a picturebox.
A timer event changes the image by assigning an image from an
imagelist to it. I've found that the code for this is causing the
application to use more and more memory until it craps out. If I
comment the code out, it's fine. Can anyone tell me if there is a way I
can manage the memory better? Is there better code for this or
something? Why is it using up memory? Any help is appreciated. The
code below is what I have within my timer event which fires once per
second...

imageIndex += 1
If imageIndex > 11 Then
imageIndex = 0
End If
If cmiShowAnimation.Checked Then
pboAnimation.Image = ilsAnimation.Images(imageIndex)
End If
 
That must not be that code that is causing problems, I let it run for some
time and I saw nothing wierd with memory - it did go up and down, but only
in a 1mb range (which to be expected). What else are you doing in the loop?
What type of images are you using in the ImageList? What OS / Framework /
VStudio versions?

~
Jeremy
 
The image types are 32 x 32 images of a clock icon that I have that
animates the hands moving around. The OS I'm using is Win 2000
Professional. The Framework is 1.0, Visual Studio ver. 7.0.9466.

I actually think it has more to do with the fact that when the form is
minimized, the amount of memory allocated decreases automatically. But
I don't know much about this, so I don't really know. I use a
NotifyIcon in the taskbar and I make the main for invisible when
minimized. The MouseDown event on the NotifyIcon brings the form back
to Normal and Visible. I have the NotifyIcon change icons every second
(with the timer event) in a certain situation to alert the user of an
event. I think this has something to do with the problem. All of this
works for several hours, but after a while, the MouseDown event on the
NotifyIcon doesn't respond, and the NotifyIcon isn't changing it's icon,
even though the app is supposed to be doing that. However, log file
entries continue to report that the app is still functioning, but it is
just unresponsive to outside user input with the NotifyIcon. The
Windows Task Manager says it's using up all the memory. I'll have to
poke around with it some more I guess. Thanks for the help.
 
Back
Top