what is the best way to track and lower GDI windows handles . .
Personally I use IARSN TaskInfo to see the number of handles my program uses, GDI included. As for lowering the number of active handles, then I would look at what in your application is using handles.
Things like (but not limited to):
- Pens
- Bitmaps
- Controls (I don't think all of them uses handles)
Do you have a specific problem with too many handles, or perhaps even a handle leak?
the easiest way to see the current usage on an end user's machine is to use task manager and look at the column "GDI Handles"
When I suspect I have GDI handle leaks I tend to run through my leak scenario once, force a garbage collection, look at task manager, run the action again with gc and check for a difference. If I find one I have used the .Net Profiler (from SciTech) which can show in detail which object causes the leak and why it is not handed back
Two links worth reading...
Resource Leaks: Detecting, Locating, and Repairing Your Leaky GDI Code