G
Guest
Recently some friends were looking at some code written by an outside
contractor. In the code, there was a great deal of use of pens and brushes
without disposing of them.
What surprised me is that the system never seemed to run out. The brushes
and pens were being created in every paint event. I suppose it's possible
that the garbage collector was getting around to them often enough to
finalize the pens and brushes, but I doubt it was happening often enough to
keep up with the use.
I've always thought of pens and brushes as very limited system resources. Is
that no longer the case with Gdi+?
Also, in a similar vein, we were discussing the use of a static pen object
to optimize drawing in a control.
Is this considered acceptable? I mean, the pen (and I presume its underlying
GDI+ handle) are going to be held for the lifetime of the app if it's
static.
Can someone help modernize my understanding of GDI?
Pete
contractor. In the code, there was a great deal of use of pens and brushes
without disposing of them.
What surprised me is that the system never seemed to run out. The brushes
and pens were being created in every paint event. I suppose it's possible
that the garbage collector was getting around to them often enough to
finalize the pens and brushes, but I doubt it was happening often enough to
keep up with the use.
I've always thought of pens and brushes as very limited system resources. Is
that no longer the case with Gdi+?
Also, in a similar vein, we were discussing the use of a static pen object
to optimize drawing in a control.
Is this considered acceptable? I mean, the pen (and I presume its underlying
GDI+ handle) are going to be held for the lifetime of the app if it's
static.
Can someone help modernize my understanding of GDI?
Pete