Possible bug in Bitmap.GetHicon()

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
 
P

Patrick Steele [MVP]

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).
 
G

Guest

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.
 
P

Patrick Steele [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top