While playing around with the progressbar I recently made, I noticed
a drop in GDI resources for each created control. No leak, just a drop
while the control was loaded. Tracked it down to the fact I was storing
an array of pens during the control's life-time. Stupid thing to do, so
I will post a change in the code soon, with some other improvements
added to the control.
Anyway, this lead me to a small test. Seems like pens and brushes are
a big factor, when it comes to GDI resources. In case your program
stores many of them, do check and see if you can do it other way, like
create and delete them "on the fly".
(I noticed EZ_GUI made software stores a bunch of brushes - may be
worth looking into..)
Win NT and 2000 may handle this better, but the following little
test steals almost 15% of my GDI resources in Windows 98, and of
course returns them when the array of pens are deleted:
------------------
a drop in GDI resources for each created control. No leak, just a drop
while the control was loaded. Tracked it down to the fact I was storing
an array of pens during the control's life-time. Stupid thing to do, so
I will post a change in the code soon, with some other improvements
added to the control.
Anyway, this lead me to a small test. Seems like pens and brushes are
a big factor, when it comes to GDI resources. In case your program
stores many of them, do check and see if you can do it other way, like
create and delete them "on the fly".
(I noticed EZ_GUI made software stores a bunch of brushes - may be
worth looking into..)
Win NT and 2000 may handle this better, but the following little
test steals almost 15% of my GDI resources in Windows 98, and of
course returns them when the array of pens are deleted:
Code:
#COMPILE EXE #INCLUDE "WIN32API.INC" FUNCTION PBMAIN() AS LONG LOCAL I AS LONG REDIM hPen(255) AS LONG FOR I = 0 TO 255 hPen(I) = CreatePen(%PS_SOLID, 1, RGB(I, I, I)) 'hPen(I) = CreateSolidBrush(RGB(I, I, I)) '<- even worse on resources.. NEXT MSGBOX "255 pens created, check your GDI resources!" FOR I = 0 TO 255 DeleteObject hPen(I) NEXT MSGBOX "255 pens deleted, check your GDI resources again!" END FUNCTION
------------------
Comment