Wiki Link: [discussion:5356]
GDI object increases till application black screen / crashes 

Aug 14 2012 at 4:12 PM
I have application that opens a number of WPF Shell windows and closes them and also opening and closing a window panel, but I see the GDI handle REGION count keeps rising from this until the WPF application black screens and crashes. Using memProfiler I have narrowed it down to the following lines of code in the ShellLibrary that cause the GDI region handle leak. Joe, I would be grateful to you if you could point me in the direction of what the fix would be?

GDI32!CreateRoundRectRgn( int, int, int, int, int, int )
Managed to native transition
Microsoft.Windows.Shell!Standard.NativeMethods._CreateRoundRectRgn( int,int,int,int,int,int )
Microsoft.Windows.Shell!Standard.NativeMethods.CreateRoundRectRgn( int,int,int,int,int,int )
Microsoft.Windows.Shell!Microsoft.Windows.Shell.WindowChromeWorker._CreateRoundRectRgn( Rect,double )
Microsoft.Windows.Shell!Microsoft.Windows.Shell.WindowChromeWorker._CreateAndCombineRoundRectRgn( IntPtr,Rect,double )
Microsoft.Windows.Shell!Microsoft.Windows.Shell.WindowChromeWorker._SetRoundingRegion( Nullable<WINDOWPOS> )
Microsoft.Windows.Shell!Microsoft.Windows.Shell.WindowChromeWorker._HandleWindowPosChanged( WM,IntPtr,IntPtr,ref bool )
Microsoft.Windows.Shell!Microsoft.Windows.Shell.WindowChromeWorker._WndProc( IntPtr,int,IntPtr,IntPtr,ref bool )
PresentationCore!System.Windows.Interop.HwndSource.PublicHooksFilterMessage( IntPtr,int,IntPtr,IntPtr,ref bool )
WindowsBase!MS.Win32.HwndWrapper.WndProc( IntPtr,int,IntPtr,IntPtr,ref bool )
WindowsBase!MS.Win32.HwndSubclass.DispatcherCallbackOperation( object )
WindowsBase!System.Windows.Threading.ExceptionWrapper.InternalRealCall( Delegate,object,int )
WindowsBase!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen( object,Delegate,object,int,Delegate )
WindowsBase!System.Windows.Threading.ExceptionWrapper.TryCatchWhen( object,Delegate,object,int,Delegate )
WindowsBase!System.Windows.Threading.Dispatcher.WrappedInvoke( Delegate,object,int,Delegate )
Skipped frame(s)
WindowsBase!System.Windows.Threading.Dispatcher.InvokeImpl( DispatcherPriority,TimeSpan,Delegate,object,int )
WindowsBase!System.Windows.Threading.Dispatcher.Invoke( DispatcherPriority,Delegate,object )
WindowsBase!MS.Win32.HwndSubclass.SubclassWndProc( IntPtr,int,IntPtr,IntPtr )
Native to managed transition
Managed to native transition
WindowsBase!MS.Win32.UnsafeNativeMethods.SetWindowPos( HandleRef,HandleRef,int,int,int,int,int )
PresentationFramework!System.Windows.Window.UpdateHwndSizeOnWidthHeightChange( double,double )
PresentationFramework!System.Windows.Window.UpdateWidth( double )
Truncated


Updating...
Page view tracker