zoukankan      html  css  js  c++  java
  • GDI对象泄漏检查的一点经验

      程序出现GDI泄漏,在GDIndicator中,Total字段的两个值不一致的情况,前面比后面大了很多,一直没有找到为何,以为是没释放就会导致不一致;
    查看了程序代码,一直无法找到泄漏的地方,于是找各种工具来查看究竟那里泄漏,直到使用 GDIView 的说明里面:

      'GDI Total' and 'All GDI' columns
    The 'GDI Total' column (a new column added on v1.05) displays the total number of all GDI handles found in the GDI table for the specified process. This means that 'GDI Total' column display the sum of the following columns: Pen, ExtPen, Brush, Bitmap, Font, Palette, Region, DC, Metafile DC, Enhanced Metafile DC, and Other GDI.
      The 'All GDI' value is taken from Windows API call (GetGuiResources), and it usually contains a value larger than 'GDI Total', probably because it also counts some internal kernel GDI objects that are not included in the GDI objects table of the process.
    Notice: If you have a problem that the 'All GDI' value is increased, while there is no leak with the other GDI values, it means that you probably have a leak in the creation of icons or cursors (Icons and cursors are created without destroying them later).

      于是查找HICON,HCURSOR的地方,发现有个释放HICON的函数,使用的是 DeleteObject ,而不是 DestroyIcon,修改之后,GDI泄漏有所缓解。

  • 相关阅读:
    一个tomcat 增加多个端口
    转项目经理
    apicloud 解析
    七行代码搞定 任意数据库中的数据迁移
    语语
    农家设计图纸
    日期再总结
    X删除数据表的新用法
    c#中各类日期的计算方法,收藏
    IIS 7.5 高并发参数配置
  • 原文地址:https://www.cnblogs.com/coldforce/p/5788179.html
Copyright © 2011-2022 走看看