ToHfont problem

  • Thread starter Thread starter tommy
  • Start date Start date
T

tommy

Hi there,

I used the floowing code to test
System.Drawing.Font.ToHfont():

int i = 0;
for(;;)
{
System.Drawing.Font font =
new System.Drawing.Font
("Arial",16,System.Drawing.FontStyle.Bold);
IntPtr hf = font.ToHfont();
Console.WriteLine
(i.ToString());
i++;
Thread.Sleep(10);

}

And I found the system broken when i reach 14000. Can
anyone explain why this happened?
 
And I found the system broken when i reach 14000. Can
anyone explain why this happened?

Because ToHFont() allocates a GDI font handle that you're not freeing,
so you're leaking resources.



Mattias
 
Back
Top