B
Bob Dankert
I have traced down a GDI object leak to the following line of code:
this.sbMain.Panels[0].Icon =
Icon.FromHandle(((Bitmap)this.imlIcons.Images[n]).GetHicon());
sbMain = StatusBar Control
imlIcons = ImageList Control
n = index
This command gets run on a timer every minute, and each time this is run I
lose/leak 3 GDI objects. Every 167 minutes I lose another 500 objects, and
after 2 days or so of this running I quickly reach the 10,000 GDI object
limit and the process crashes. What is the best way to handle this so I do
not lose/leak these GDI objects?
Oddly, when I create a sample project using the same code I only leak 1 GDI
object. This is still one too many, but I am not sure why I leak 3 in my
main application and only 1 in my sample? (taking out this one line of code
from my main app eliminates the leak and I have verified it is only being
executed once per 60 seconds, so I am certain it is leaking 3 GDI objects)
Thanks,
Bob Dankert
this.sbMain.Panels[0].Icon =
Icon.FromHandle(((Bitmap)this.imlIcons.Images[n]).GetHicon());
sbMain = StatusBar Control
imlIcons = ImageList Control
n = index
This command gets run on a timer every minute, and each time this is run I
lose/leak 3 GDI objects. Every 167 minutes I lose another 500 objects, and
after 2 days or so of this running I quickly reach the 10,000 GDI object
limit and the process crashes. What is the best way to handle this so I do
not lose/leak these GDI objects?
Oddly, when I create a sample project using the same code I only leak 1 GDI
object. This is still one too many, but I am not sure why I leak 3 in my
main application and only 1 in my sample? (taking out this one line of code
from my main app eliminates the leak and I have verified it is only being
executed once per 60 seconds, so I am certain it is leaking 3 GDI objects)
Thanks,
Bob Dankert