Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

Being built upon COM means that DirectDraw follows certain rules that employ reference counts to manage object lifetimes. For a conceptual overview, see the COM documentation; a DirectDraw-centered discussion of the topic is found in Parent and Child Object Lifetimes.

By COM rules, when an interface pointer is copied by setting it to another variable or passing to another object, that copy represents another reference to the object, and therefore the IUnknown::AddRefmethod of the interface must be called to reflect the change.

Not only should you follow COM reference counting rules when working with DirectDraw objects, but you should become familiar with the situations in which DirectDraw internally updates reference counts.

Some DirectDraw methods — mostly those involving complex surface flipping chains — affect the reference counts of the surfaces involved, while methods involving clippers or palettes affect the reference counts of those objects.

Knowing about these situations can make the difference in your application's stability and can prevent memory leaks.

For more information, see Parent and Child Object Lifetimesin Working with DirectDraw Objects.