Hi all, I was wondering if the postquitmessage api deletes objects(bitmaps & brushes) on exit or will I have to delete it manually. I looked through msdn but really got no clear answers. Thanks for your replies.
Posted on 2003-08-30 05:17:43 by bubba
When your application exits all of the GDI resources that it created are freed. This includes bitmaps, cursors, icons, brushes, pens and DC's. However things like DC's can very quickly eat up any GDI memory that you have. Though in NT you are limited only by the amount of memory in your system, in 9x/ME there is only 64K of GDI memory available to Windows and all applications share it. Logical pens are a part of that 64K of memory. You should be freeing resources as soon as they are not needed. I expressly delete everything that I create, just seems neater that way. You can google for MemProof, that will tell you if you have any objects left over at the end of your program and even advise you on which command is used to destroy them.
The system automatically deletes these resources when the process that created them terminates, however, calling the appropriate function saves memory and decreases the size of the process's working set.
Posted on 2003-08-30 05:40:41 by donkey
Posted on 2003-08-30 05:47:32 by donkey
Thanks Donkey, my reasoning for asking this is because my program will be really graphical. I have a bitmaped background and four controls each using a mouseover effect. I'm going to do a deleteobject just in case. Going to look into that memproof you mentioned. :)
Posted on 2003-08-30 05:53:02 by bubba
No Probs Bubba,

You should also be aware that MemProof is not the be all, end all of GDI leak checking. If you have a run-time leak, like not unselecting a bitmap from a memory DC before deleting the DC and bitmap it will not report it. This will lead to a very fast and complete loss of resource space in 9x (could take quite a while in NT). Memproof will check that all the resources created were deleted not that they were properly deleted. In the memDC/bitmap example you must first select the old object back into the DC before you delete the DC and bitmap. I ran into this problem recently and it took a while to figure it out as it is not documented anywhere. But I highly reccomend memproof, it has saved me a few headaches.
Posted on 2003-08-30 06:01:30 by donkey