GDI processes the dotnet application

My clean DotNET library works like a plugin inside an unmanaged desktop application. I get a stable (albeit low) flow of crash reports that seem to indicate a problem with the GDI descriptors (fonts in error messages, etc. Return to the system font, all kinds of controls are displayed, massive crashes soon after) .

My forms have several controls, but I do a lot of GDI + drawings in User elements. What a good way to tell how many pens I use, or even a leak?

Thanks David

+6
source share
7 answers

GDIView Ray Vega, :

[DllImport("User32")] 
extern public static int GetGuiResources(IntPtr hProcess, int uiFlags);

  public static void GetGuiResourcesGDICount()      
  { 
      //Return the count of GDI objects.          
      Console.WriteLine("GDICount"+GetGuiResources(System.Diagnostics.Process.GetCurrentProcess().Handle, 0));      
  }

  private void button1_Click(object sender, System.EventArgs e)
  {
      GetGuiResourcesGDICount();
  }

GDIView , , ; GetGuiResources , , .

Label , UserControl . GDI. , , Label . , , , UserControl .

+5

, .

View > Select Columns... GDI.

+3

GDIView ( ):

GDIView - , GDI (, , , ..), . GDI, . , GDI .

alt text
(: nirsoft.net)

, , : Options → Auto Refresh → Every [N] seconds

+3

"" TaskMgr.exe. + , GDI.

. , , Dispose(). . , , .

+1

, , IDisposable.Dispose GDI +, . # using, :

using(Brush brush = ...)
{
    ...
}

, FxCop , Team System Visual Studio, , Dispose.

Dispose - , , .

+1

GDIObj, , , Windows: Win32 GDI DirectDraw .

, GDI, DC, Region, Bitmap, Palette, Font, Brush ..

(However, it provides only account information, and GDIView contains more detailed descriptor information.)

+1
source

All Articles