Best regards,
William
Sorry for my spelling error. "set_return_type" will increase the
reference count.
I suspect perhaps incorrect _var usage is the culprit here as it's the
most common cause of CORBA memory leaks in C++. For example, you
above statements could have omitted the CORBA::release(typeCode) call
if the typeCode variable was a _var type.
i.e. CORBA::TypeCode_var typeCode = orb->create_interface_tc(...)
Likewise I suspect that your pCorbaRequest variable is also a _ptr
type instead of a _var type. Can you confirm?
_var types certainly ease CORBA C++ programming since it takes care of
the memory management issues for you. Once the _var scope closes, the
_var takes care of decrementing the reference count and freeing the
memory if necessary. This means it eliminates the need for
CORBA::release() calls which are especially dangerous in light of
exception handling. For example, something like this could result in
a memory leak...
TypeCode_ptr tc = orb -> create...()
doSomeFunction(tc); // <- throws an exception
CORBA::release(tc); // <- never gets called!
Cheers.
--Dion
If I use CORBA::TypeCode_var, I have no need to call
CORBA::release() , because they are equivalent. And pCorbaRequest also
belongs to _var type.
In fact, my idl interface is like: anotherInterface create();
First I create anotherInterface's typecode throuth
create_interface_tc,
then I call set_return_type, at last pCorbaRequest->invoke() is
called.
Actually I still don't know which step results in the memory leak.
I think that "pCorbaRequest-->invoke()" has no problem, because after
I got anotherInterface, it has no memory leak to call the method of
anotherInterface.
So the culprit is create_interface_tc or set_return_type mostly.