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泄漏有所缓解。

  • 相关阅读:
    为博客园选择一个小巧霸气的语法高亮插件
    再议 js 数字格式之正则表达式
    [扯蛋] 项目说
    浅谈 js 语句块与标签
    Yii 自定义模型路径
    js小记 function 的 length 属性
    js拾遗:appendChild 添加移动节点
    浅谈 IE下innerHTML导致的问题
    浅谈 js 数字格式类型
    [hihoCoder] 第四十九周: 欧拉路·一
  • 原文地址:https://www.cnblogs.com/coldforce/p/5788179.html
Copyright © 2011-2022 走看看