B
Barry Anderberg
I'm using the .NET Memory Profiler by Sci Tech and I wrote a little
test application to verify something odd I observed and it appears
that System.Drawing.Font fails to dispose of its FontFamily.
I run the following code:
// BEGIN
while( true )
{
System.Drawing.Graphics dc=lblClock.CreateGraphics();
dc.Clear(Color.White);
Font f=new Font("Arial", 10, FontStyle.Bold);
dc.DrawString(DateTime.Now.ToString("yyyy MMM dd, hh:mm:ss",
ClockDTFI), f, Brushes.Black, 5, 0);
f.Dispose();
dc.Dispose();
}
// END
This is just to see if I can generate lots of fonts, dispose of them,
and verify that they are disposing of their unmanaged resources, but
the .NET Memory Profiler shows that there are *thousands* of
FontFamily objects that haven't been disposed.
I am not certain but I suspect this is causing a memory leak because
my program's memory grows and grows.
Even if I call f.FontFamily.Dispose() it still says there are
thousands of FontFamily objects that haven't been disposed.
test application to verify something odd I observed and it appears
that System.Drawing.Font fails to dispose of its FontFamily.
I run the following code:
// BEGIN
while( true )
{
System.Drawing.Graphics dc=lblClock.CreateGraphics();
dc.Clear(Color.White);
Font f=new Font("Arial", 10, FontStyle.Bold);
dc.DrawString(DateTime.Now.ToString("yyyy MMM dd, hh:mm:ss",
ClockDTFI), f, Brushes.Black, 5, 0);
f.Dispose();
dc.Dispose();
}
// END
This is just to see if I can generate lots of fonts, dispose of them,
and verify that they are disposing of their unmanaged resources, but
the .NET Memory Profiler shows that there are *thousands* of
FontFamily objects that haven't been disposed.
I am not certain but I suspect this is causing a memory leak because
my program's memory grows and grows.
Even if I call f.FontFamily.Dispose() it still says there are
thousands of FontFamily objects that haven't been disposed.