Page 1 of 1

[solved] GUI handle leak

Posted: Sat Dec 01, 2012 8:33 pm
by breeze4me
1. run this code.

Code: Select all

If OpenWindow(0, 0, 0, 222, 200, "My Window", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
2. run Windows Task Manager. (for seeing the handle increment)

3. switch between the 'My Window' and other window, then see the handle increment.
(activate it, then deactivate it, activate it again)
if you do this repeatedly, then you will see the continuous increment of the handle.

tested on Win7 pro 32bit.

Re: [5.00 x86] GUI handle leak

Posted: Sun Dec 02, 2012 5:47 pm
by netmaestro
Does this count increment?

Code: Select all

ProcessHandle = OpenProcess_(#PROCESS_ALL_ACCESS,#False,GetCurrentProcessId_())

If OpenWindow(0, 0, 0, 222, 200, "My Window", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
  StickyWindow(0, 1)
  TextGadget(0,10,10,100,20,"Total GDI Handles:")
  TextGadget(1,110,10,60,20,"")
  AddWindowTimer(0,1,100)
  Repeat 
    ev = WaitWindowEvent()
    Select ev
      Case #PB_Event_Timer
        gdicount = GetGuiResources_(ProcessHandle, 0) ; 0 = #GR_GDIOBJECTS
        SetGadgetText(1, Str(gdicount))
    EndSelect
  Until ev = #PB_Event_CloseWindow
EndIf

Re: [5.00 x86] GUI handle leak

Posted: Sun Dec 02, 2012 7:43 pm
by breeze4me
No, it doesn't increase.

Re: [5.00 x86] GUI handle leak

Posted: Sun Dec 02, 2012 8:40 pm
by breeze4me
I found a solution. It was due to Windows IME.

Code: Select all

If OpenWindow(0, 0, 0, 222, 200, "My Window", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
  ImmAssociateContext_(WindowID(0), 0)  ;  <--- it solves the problem.
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: [solved] GUI handle leak

Posted: Thu Dec 27, 2012 5:55 pm
by Fred
Sounds like a driver problem on your PC, can anyone else confirm ?

Re: [solved] GUI handle leak

Posted: Thu Dec 27, 2012 11:27 pm
by Zebuddi123
Doesnt increase on Win7 ultimate64 pb510b1 x86 x64, pb5.00 x86 x64 tallys with with "Comodo killswitch"

+ Bonus Procedure for future checking :D

Code: Select all

ProcedureDLL.i GetNumberOfThisProcessHandles(type.i) ; GDI=0, peak count GDI objects=2 |  User Objects=1, peak count USER objects=4
	processhandlecount.i = GetGuiResources_(OpenProcess_(#PROCESS_ALL_ACCESS,#False,GetCurrentProcessId_()), 0)
	ProcedureReturn processhandlecount
EndProcedure


If OpenWindow(0, 0, 0, 322, 200, "My Window", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
	StickyWindow(0, 1)
	TextGadget(0,10,10,100,20,"Total GDI Handles:")
	TextGadget(1,110,10,160,20,"")
	AddWindowTimer(0,1,100)
	Repeat 
		ev = WaitWindowEvent()
		Select ev
			Case #PB_Event_Timer
				;gdicount = GetGuiResources_(ProcessHandle, 0) ; 0 = #GR_GDIOBJECTS
				gdi$="GDI Objects "+Str(GetNumberOfThisProcessHandles(0))
				user$="User Objects "+Str(GetNumberOfThisProcessHandles(1))
				SetGadgetText(1, gdi$+" "+user$)
		EndSelect
	Until ev = #PB_Event_CloseWindow
EndIf


Zebuddi. :D

Re: [solved] GUI handle leak

Posted: Fri Dec 28, 2012 12:29 am
by breeze4me
There is the same problem on clean installed Windows 7 home premium x86 Korean with SP1.(on Win 7 pro x64, no problem at all)
It seems to be a Windows IME's bug. (it occurs only when the IME window is hidden by control panel setting. Korean version only? I don't know)
Not only a window compiled by PB, but also all the windows. So it's not a PB's bug, I think.

Could you move this thread to a proper forum?

Edit:
Additional info: It's a registry handle leak related to the IME.