Do I delete instance data of a com object in release or in destructor?

Release is supposed to, as the name says, release instance data. This is also the task of a destructor in c++. Now where should i release instance data? Which one is called first?


A COM object keeps track of how many times AddRef and Release have been called on it. This is called the RefCount.

When the RefCount drops to zero, it means no one is holding a reference to the object anymore, and it deletes itself.

You and your code never really know exactly what other elements of a program may be holding a reference to a COM object, so you should not explicitly delete the object.

Rather, you should call Release when you are done with it. When the last Release is called, the object will delete its own data.

Release is supposed to decrement the reference count. Only if the reference count reaches zero, the object is destroyed an the destructor called.

Need Your Help

Background image change on scroll

javascript jquery

I would like to change background image of one div on scrolling the browser.

Typescript objects serialization?

javascript json serialization typescript

Are there any means for JSON serialization/deserialization of Typescript objects so that they don't loose type information? Simple JSON.parse(JSON.stringify) has too many caveats.