I got GDI Resources Bloat
Posted on 2002-07-25
I'm in the final throes of finishing my program. A friend told me that I should check for resource leaks by using the Task Manager in Windows 2000 and looking at the "GDI Objects" numbers. They should increase and then decrease back to the same number as I open documents and then close them. If I just open and close them, the numbers do go back to the same number. But if I hit the "Open" button or change a font or do any number of things, the numbers don't go back to the previous number. In fact, as I open and close documents and make changes the numbers keep getting higher. I tried plugging all the holes by using DeleteObject in the destructors for any CFont that are held by a class. I've released all my DCs. I think I got them all. But the numbers still increase (in fact, and this may be my imagination, it seems to be getting worse).
My question is: am I making myself nuts for no reason? Perhaps these numbers in the GDI Objects column of Task Manager don't really mean I'm leaking resources. I know it's kind of general question but do increasing numbers mean a resource leak and what can anyone think of to try to fix it? What are the common reasons for resource leaks besides not releasing any GetDCs or deleting font objects. BTW, I thought CFont would automatically delete any GDI objects when it goes out of scope - ie when the class dies when I close the document. Any help is greatly appreciated by my psychiatrist.