Possible bug in Bitmap.GetHicon()

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I believe I found a bug in the Bitmap.GetHicon() method that leads to a memory leak.

When put in a loop, that continuously updates the Icon, even as slow as once a second, memory usage starts to climb and will eventually crash the program and cause strange behavior in Windows.

I am running Win2K Professional and with VS .NET 2003 Enterprise Architect.

If you want the code that I have, please give me your email Address, I'll email it to you. It was just something I did for entertainment.

Thank You,
R. Jason Gabourie
 
I believe I found a bug in the Bitmap.GetHicon() method that leads to a memory leak.

When put in a loop, that continuously updates the Icon, even as slow as once a second, memory usage starts to climb and will eventually crash the program and cause strange behavior in Windows.

Are you releasing the icon handle when you're done with it via
"DestroyIcon" (you'll have to PInvoke it).
 
How do you call DestroyIcon? And what's PInvoke? I am new to C# and the .NET Framework, and have not seen either of these commands before. Any help you can give would be greatly appreciated.

Thank you.
 
How do you call DestroyIcon? And what's PInvoke? I am new to C# and the .NET Framework, and have not seen either of these commands before. Any help you can give would be greatly appreciated.

static extern int DestroyIcon(IntPtr hIcon);

PInvoke is short for "Platfom Invoke". It's a way for managed .NET code
to call unmanged code. See:

http://www.pinvoke.net for more information.
 
Back
Top