views:

601

answers:

2

My application logs an exception after running for 6 hours:

OS Version: Microsoft Windows NT 5.1.2600 Service Pack 3 (5.1.2600.196608)

.NET Version: 2.0.50727.3082

SQL Server Version: 9.00.4035.00

SQL Server Level: SP3

SQL Server Edition: Standard Edition

Error Message: Parameter is not valid.

Exception type: System.ArgumentException

Source: System.Drawing

Stack Trace: 
at System.Drawing.Graphics.GetHdc()
at System.Windows.Forms.ImageList.GetBitmap(Int32 index)
at System.Windows.Forms.ImageList.ImageCollection.get_Item(Int32 index)
<<< MY code >>>
+2  A: 

GDIView worked for me. It pointed to a Font leak. I did a search for ToHfont(). The rest is history.

GregC
http://www.nirsoft.net/utils/gdi_handles.html
GregC
I wished Nir Sofer would speak up, so I could give him the well-deserved credo.
GregC
Thanks for that! it just helped me solve my GDI handles hitting the 10K limit.
dtroy
+3  A: 

Recently I've created a simple class that calls GetGuiResources() function in both the constructor and destructor and reports any differences in GDI object counts. Using it as a scoped object in a few functions helped me plug GDI leaks in the code.

macbirdie
GDIView basically does the same thing.. Yet there's no code to write.
GregC