News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Delete After Use

Started by raleeper, July 17, 2007, 11:17:55 AM

Previous topic - Next topic

raleeper

Where is an explanation of the reason for the incessant [soft] imperatives in the SDK to:

    When you no longer need the bitmap[or other], call the DeleteObject function to delete it.

?

I usually just ignore unexplained imperatives, except to chalk up a strike against the issuer, but here I would like to know more.

Thanks.

hutch--

Its simple really, selecting an object involves allocating memory behind the scenes, releasing the object deallocates the memory. Fail to do so and you can easily produce an application that keeps allocating memory every time the window size is changed or some other image change type of event.

Practice the old rule, what goes up must come down, if its allocated, deallocate it after. GDI Objects work much the same way.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

TNick

When you create the bitmap (or you create a DC, or you're opening a file) memory is commited to hold that object's data. When you don't need that object, the memory should be released. I think this is all about ...

Nick

[After a few seconds]
Oops! Hi, hutch! I should read those warnings ...  ::)