Lifetime of Storage Objects

Storage objects are freed in the same manner as other COM objects. Thus, when a consumer no longer needs a storage object created by a provider, it calls Release on that object. If the provider supports a VARIANT_FALSE value for DBPROP_MULTIPLESTORAGEOBJECTS, the consumer must always call Release on the storage object before it can open a new storage object on any row. Releasing a reference to a storage object does not free the storage object. Doing so only causes the reference count on the storage object to be decremented. When the object's reference count reaches zero, the object is freed automatically.

In addition, a storage object might enter a zombie state if one of the following events occurs:

  • The consumer calls Release to release the rowset containing the row.

  • The consumer calls IRowset::ReleaseRows to release the row containing the storage object.

  • The consumer calls ITransaction::Commit or ITransaction::Abort, and the retaining flag is set so that the rowset enters a zombie state.

  • The consumer deletes the row containing the storage object and transmits the deletion to the underlying data store.

When a storage object enters a zombie state, it is not automatically released. Instead, if the consumer calls any method on the storage object except Release, that method returns E_UNEXPECTED. It is the consumer's responsibility to release the storage object, even if it is in a zombie state.

This topic is a part of: