GDI leak in NTextBox?
Print Topic | Close Window

By Craig Swearingen - 7 Years Ago
I've been testing my application looking for leaks.  Specifically, looking for GDI leaks I've been using the Bear tool to help with this:

In my application I have a global Font object that I use in various places within my application.  On one of my windows I set the Font property to be this global Font on both an NTextBox and an NTreeViewEx widget.  When loading this window and viewing in the Bear tool I see the application GDI Font total go up by one.  When I close this window the GDI Font total doesn't change though I know my window is being disposed of correctly.  Every time I open and close the window my GDI Font total goes up one more.

When I stop assigning the window's NTextBox Font property my global Font object I don't see this happening in the Bear tool.  It seems like the NTextBox is not disposing of the Font its creating when the widget is disposed.  Is there a Font GDI leak in the NTextBox code?
By Nevron Support - 7 Years Ago
Hello Craig,

Could you check this issue with System.Windows.Forms.TextBox instead of NTextBox because NTextBox inherits from it, and NTextBox does not use Font property anywhere in its implementation.

By Craig Swearingen - 7 Years Ago
Thanks for the idea.  Yes, you're right.  When I replace the NTextBox with a TextBox I continue to see the same issue that looks like a leak.  Not sure it is but its definitely not a Nevron issue.