I am having several memory issues with an application with a long lifespan; I studied drawing methods to ensure that the brushes are correctly positioned. In the case when Brusha brush is created in the function argument after a call?
Brush
The case is described below:
g.DrawString(valueText, Font, new SolidBrush(Color.Red),
I am not quite sure, but I do not believe that this is so. That would be safer:
using(var redBrush = new SolidBrush(Color.Red) { g.DrawString(valueText, Font, redBrush); }
No, you have to do it manually. However, consider the classes Brushesand SystemBrushes, for ready-made brushes, which you can use without creating new ones (and you also don't need / don't need to manage).
Brushes
SystemBrushes