Re: Re[2]: win32lib v0.57.4 released
- Posted by Derek Parnell <ddparnell at bigpond.com> May 11, 2002
- 423 views
----- Original Message ----- From: "Wolf" <wolfritz at KING.IGS.NET> To: "EUforum" <EUforum at topica.com> Subject: Re: Re[2]: win32lib v0.57.4 released > > Since Derek's 'away"... > > >> > - "by Thomas Parslow". GDI resource leak using wPuts and queryFont > > Does this example trash XP as nicely ! ...as it does Win98 ? > Just *minimize* after running ! > ( 'hard' reboot may be req. ...if you run it a few times... :( ) > Works OK using 0.55.5. > ---- > include win32lib.ew > constant > blank=create(Window,"",0,10,10,300,200,0) > setWindowBackColor(blank,BrightWhite) > procedure draw(integer i) > if remainder(i,2) then setPenColor(blank,Blue) > else setPenColor(blank,Red) end if > drawRectangle(blank,1,1,1,99,99) > end procedure > showWindow(blank,1) > for i = 1 to 20000 do > draw(i) > end for > WinMain(blank,Normal) > ---- Okay, what was happening is that drawRectangle(), as did many other routines, assume that it was running from an onPaint event handler. Win32lib automatically releases all the resources after a Paint event handler completes. In your example above, the code is not running inside a Paint event handler so it never tries to clean up. I've fixed this now so that those routines that grab resources, expecting them to be freed up by the end of a Paint event handler, will free them themselves if NOT being run inside a paint handler. Also, I've made releasePaintResources() and releaseResourcesForID() as a global procedures so that you can 'manually' call them if you are having other resource leak issues. --------- Derek.