代码之家  ›  专栏  ›  技术社区  ›  GregC Benjamin Baumann

如何捕获(并希望修复)GDI资源泄漏

  •  4
  • GregC Benjamin Baumann  · 技术社区  · 17 年前

    我的应用程序在运行6小时后记录了一个异常:

    操作系统版本:微软Windows NT 5.1.2600 Service Pack 3(5.1.2600.196608)

    SQL Server版本:9.00.4035.00

    SQL Server级别:SP3

    SQL Server版本:标准版

    错误消息:参数无效。

    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 回复  |  直到 17 年前
        1
  •  4
  •   macbirdie    17 年前

    最近我创建了一个简单的类,它调用 GetGuiResources() 构造函数和析构函数中的函数,并报告GDI对象计数的任何差异。在一些函数中将其用作作用域对象有助于我在代码中插入GDI泄漏。

        2
  •  2
  •   themadmax    9 年前

    GDIView 对我有效。它指出了字体泄漏。我搜索了ToHfont()。剩下的就是历史了。