Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Memory leaked when I used DII with Orbacus

3 views
Skip to first unread message

William

unread,
Jun 19, 2007, 3:04:35 AM6/19/07
to
Hi,
I used CORBA DII in my client application which is developed
through C++. The orb is Orbacus 4.3, and my application runs on AIX
5.3. Below are some code pieces:
CORBA::TypeCode_ptr typeCode = create_interface_tc(......);
......
pCorbaRequest->set_return_type(typeCode);
CORBA::release(typeCode);
......
By testing, I find that my client application has memory leak. The
function "create_interface_tc" allocate memory, but "set_return_type"
will recrease the reference count.
Now I don't still know how to free the memory, please help me.

Best regards,
William

William

unread,
Jun 19, 2007, 10:39:38 AM6/19/07
to

Sorry for my spelling error. "set_return_type" will increase the
reference count.

d_p...@hotmail.com

unread,
Jun 20, 2007, 9:16:52 AM6/20/07
to

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

William

unread,
Jun 22, 2007, 9:02:57 AM6/22/07
to

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.

William

unread,
Jun 29, 2007, 11:32:01 AM6/29/07
to
> Actually I still don't know which step results in the memory leak.- Hide quoted text -
>
> - Show quoted text -

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.

0 new messages