The following snippet is taken from an example implementation of ComboBox::DrawItem on this MSDN page :
e.Graphics.FillRectangle(new SolidBrush(animalColor), rectangle);
I doubt this part: new SolidBrush(animalColor)
Since this is not intentionally assigned to Dispose and is not completed in using , I assume this is also an example of a bad shape, as the SolidBrush object will be created and will never be deleted.
I have always worked under the assumption that I should use one of the above removal mechanisms directly or the risk of memory leak.
Is it right, or is there some deeper hidden disposal that I don't know about? Perhaps because it was never bound to a variable?
c #
Donboitnott
source share