Re: DispatchPtr not releasing

Normand Mongeau <[email protected]> Thu, 1 Sep 2005 16:32:49 -0400
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <008c01c5af34$51fc8130$6600a8c0@tocsh>
It's not easy to post code. I'll try to explain more in depth.

DispatchPtr instances are kind of "smart" instances, because somewhere deep
in the machinery of COM a Release gets sent when instances go out of scope.
This is easily verified with the following: create a COM class, and
implement a FinalRelease method just to track when it gets called.  So if
you have code like this:

instA = new A().

when the instA variable goes out of scope the FinalRelease method will get
called automatically (it's called by the Release() method).

My problem is that if I need to pass the A instance to another COM class,
the A never gets finalized.  This is also easy to verify with code like
this:

instA = new A().
instB = new B().
instB->invokeSomeMethodPassingTheOtherInstance(instA).

the finalization of the B instance will happen, but not the finalization of
the A instance.

This only happens through JAWIN.  It's as if an extra refCount was added to
the A instance, thus not releasing it.

Regards,

Normand

----- Original Message -----
From: "Morten Andersen" <[email protected]>
To: <[email protected]>
Sent: Thursday, September 01, 2005 11:55 AM
Subject: Re: [JAWIN] DispatchPtr not releasing


> Hi Norm,
>
> I am at least not sure I understand your problem 100%. So if possible,
> can you please post a couple of lines of code that shows your problem
>
> Best Regards, and sorry for not being so quick in answering.
> Morten
>
> Normand Mongeau wrote:
>> So nobody knows about this, or did I not formulate my question clearly
>> enough?
>>
>> Norm
>>
>> ----- Original Message -----
>> From: "Normand Mongeau" <[email protected]>
>> To: <[email protected]>
>> Sent: Monday, August 29, 2005 5:36 PM
>> Subject: [JAWIN] DispatchPtr not releasing
>>
>>
>>> Hi,
>>>
>>> I have a problem with subclasses of DispatchPtr, which do not get
>>> released
>>> when they are passed as arguments of method invocations.
>>>
>>> To determine this, I implemented a FinalRelease method in my subclass,
>>> and
>>> when I instantiate my subclass and do nothing special with it, the
>>> FinalRelease method of my COM object gets called.  But if I send the
>>> instance as an argument to another COM object (the method does nothing
>>> with the instance received), then the FinalRelease method of my COM
>>> never
>>> gets called.
>>>
>>> Does this ring a bell with anyone?
>>>
>>> Thanks,
>>>
>>> Norm
>>
>>