[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: MysterX changes exp-tagged



>> I'm probably being naive, but what about using a finalizer to
>> decrement the count?

Several others have suggested this.

>this is not the problem. of course this is done.
>
>the problem is that "some" COM servers do increment 
>the internal m_cRef on CoCreateInstance(),
>thus the internal servers and local clients refcounts are not in synch.
>However, a QueryInterface() call should increment the server m_cRef through 
>the given interface pointer. Some server implementors mix this up.

Hmmmm, the examples of CoCreateInstance() and CoCreateInstanceEx()
in Box's book, Essential COM, appear to assume that an AddRef()
has been called by the server.  That would appear to be consistent
with the reference-counting rules in the COM spec.  In any case, 
some servers appear to do the wrong thing in certain situations.

MysterX was *already* using either a finalizer 
(if the object is GC'd) or a custodian (if the thread shuts down) 
to call Release().  The problem is that adding a gratuitous AddRef() 
means that the reference count never goes to zero, hence the object 
hangs around.

I'm probably going to extend the new mechanism to handle mx-element%'s
and mx-iunknown's, since they might suffer the same problem.

-- Paul