Discussion:
[omniORB] Cleaning up after string_to_object
Pearl Rothman
2011-09-01 19:56:22 UTC
Permalink
Hi,

Is there a way for me to release memory of an object that was allocated
using string_to_object but is no longer being used?

I specifically want to clean up connections that are no longer valid. I'm
concerned that if there is some sort of networking issue, I will have memory
allocated for multiple connections to a server when the failed connections
will no longer be valid.

Thanks,
Pearl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20110901/8ab6effd/attachment.htm
Brian Neal
2011-09-01 20:45:24 UTC
Permalink
Post by Pearl Rothman
Hi,
Is there a way for me to release memory of an object that was allocated
using string_to_object but is no longer being used?
If you are using C++, store the result of string_to_object() in a
*_var. The _var will call CORBA::release() on the object reference
when the var goes out of scope. For more information, see the IDL to
C++ language mapping or the Henning & Vinoski book.

Best,
BN
Pearl Rothman
2011-09-01 23:45:45 UTC
Permalink
I am storing the result in a _CORBA_ObjRef_Var. Should I be storing it in a
_CORBA_ObjRef_Var* ? Then should I be calling delete on the
_CORBA_ObjRef_Var* ?

Thanks
Post by Brian Neal
Post by Pearl Rothman
Hi,
Is there a way for me to release memory of an object that was allocated
using string_to_object but is no longer being used?
If you are using C++, store the result of string_to_object() in a
*_var. The _var will call CORBA::release() on the object reference
when the var goes out of scope. For more information, see the IDL to
C++ language mapping or the Henning & Vinoski book.
Best,
BN
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20110901/f5b23fab/attachment.htm
Brian Neal
2011-09-02 00:00:49 UTC
Permalink
Why not use CORBA::Object_var? For example:

CORBA::Object_var obj = orb->string_to_object(s);

That's what the IDL to C++ mapping describes. I am not familiar with
the types _CORBA_ObjRef_Var, etc. Are those internal types used by
omniORB? If you stick to the mapping you'll be fine (and your code
will be more portable).

Regards,
BN
Post by Pearl Rothman
I am storing the result in a _CORBA_ObjRef_Var. Should I be storing it in a
_CORBA_ObjRef_Var* ? Then should I be calling delete on the
_CORBA_ObjRef_Var* ?
Thanks
Post by Brian Neal
Post by Pearl Rothman
Hi,
Is there a way for me to release memory of an object that was allocated
using string_to_object but is no longer being used?
If you are using C++, store the result of string_to_object() in a
*_var. ?The _var will call CORBA::release() on the object reference
when the var goes out of scope. For more information, see the IDL to
C++ language mapping or the Henning & Vinoski book.
Best,
BN
Loading...