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

  • 相关阅读:
    伟东云学堂—几何画板学习
    京北鲤鱼----创客教育
    几何画板学习网站
    快乐的搬运工
    少儿编程网
    科技学堂 Arduino轻松学
    跟张老师学硬件arduino板
    科技学堂 Arduino传感器入门
    巧办网
    项目:git+gitlab+jenkins+ansible上线网站
  • 原文地址:https://www.cnblogs.com/coldforce/p/5788179.html
Copyright © 2011-2022 走看看