Discussion:
[omniORB] How to destroy objects
Stefan Walter
2013-07-02 13:18:23 UTC
Permalink
Hello,

how do I destroy objects in omniORB which are not longer required.

If you look at the code below (from the echo example), the only destroy
happens on the "orb" and not on the "obj" at the end.

What if I don't need the "obj" anymore? How can I destroy it?

Thanks and Regards,
Stefan
-------------------------------------------------------------------------------------------------------
intmain (int argc, char **argv) { try { CORBA::ORB_var orb =
CORBA::ORB_init(argc, argv);
CORBA::Object_var obj = getObjectReference(orb);
Echo_var echoref = Echo::_narrow(obj);
for (CORBA::ULong count=0; count < 10; count++) hello(echoref);
orb->destroy(); } catch(CORBA::TRANSIENT&) { cerr << "Caught system
exception TRANSIENT -- unable to contact the " << "server." << endl; }
catch(CORBA::SystemException& ex) { cerr << "Caught a CORBA::" <<
ex._name() << endl; } catch(CORBA::Exception& ex) { cerr << "Caught
CORBA::Exception: " << ex._name() << endl; }
catch(omniORB::fatalException& fe) { cerr << "Caught
omniORB::fatalException:" << endl; cerr << " file: " << fe.file() <<
endl; cerr << " line: " << fe.line() << endl; cerr << " mesg: " <<
fe.errmsg() << endl; } return 0;}

__________________________________________
The content of this e-mail is confidential and restricted for the use of
the intended recipient only. If you are not the intended recipient
please inform the sender immediately and delete this e-mail and any
attachments. We cannot accept liability for any damage incurred as a
result of software viruses and advise that you carry out your own virus
checks before opening any attachment.

Der Inhalt dieses E-Mails ist vertraulich und f?r die alleinige
Verwendung durch den beabsichtigten Empf?nger bestimmt. Falls Sie nicht
der beabsichtigte Empf?nger sind, bitten wir Sie den Absender umgehend
zu informieren und dieses E-Mail samt angeschlossenen Dateien zu
l?schen. Wir k?nnen keine Haftung f?r allf?llige Sch?den ?bernehmen,
die aufgrund von Software-Viren entstehen, und empfehlen Ihnen, selbst
Virenpr?fungen durchzuf?hren, bevor Sie eine Anlage ?ffnen.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20130702/2b3fc8a6/attachment.html>
Brian Neal
2013-07-02 19:22:06 UTC
Permalink
Post by Stefan Walter
how do I destroy objects in omniORB which are not longer required.
If you look at the code below (from the echo example), the only destroy
happens on the "orb" and not on the "obj" at the end.
If you want to explicitly tear down the CORBA environment you can call
orb->destroy(). This would normally happen upon program exit anyway.
Post by Stefan Walter
What if I don't need the "obj" anymore? How can I destroy it?
In the example code:

CORBA::Object_var obj = getObjectReference(orb);

The Object_var will automatically call CORBA::release() on the object
reference when its destructor runs. You'll see a lot of these _var
types in the IDL to C++ mapping, and they all perform cleanup actions
like this.

For more information see the IDL to C++ mapping document, and / or the
Advanced CORBA Programming with C++ book by Henning & Vinoski.

-BN
Duncan Grisby
2013-07-03 09:37:34 UTC
Permalink
Post by Stefan Walter
how do I destroy objects in omniORB which are not longer required.
Can you clarify what you are talking about destroying? There are at
least two things you might mean:

1. On the client side, release the object reference.
2. On the server side, deactivate the object and delete the servant.

In CORBA, those two things are totally separate concerns. Client object
references are reference counted, and the Echo_var holder automatically
releases its reference when it goes out of scope.

The lifetime of server-side object activations is completely unaffected
by whether any clients hold object references. If you want to get rid of
the server-side objects, you must write server-side code to do so. It is
common to define a destroy() method in your IDL, for example, so a
client can dispose of an object when it has finished with it. To
deactivate an object, you call deactivate_object on the POA it is
activated within.

In more complex situations, you might want to implement some sort of
evictor or timeout that automatically deactivates objects that are no
longer in use. It all depends upon what you want the semantics to be.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- duncan at grisby.org --
-- http://www.grisby.org --
Stefan Walter
2013-07-03 09:42:15 UTC
Permalink
Dear Duncan,

I mean how to release the object reference on client side.

Regards,
Stefan
Von: Duncan Grisby <duncan at grisby.org>
An:Stefan Walter <Stefan.Walter at lisec.com>
CC:<omniorb-list at omniorb-support.com>
Datum: 03.07.2013 13:38
Betreff: Re: [omniORB] How to destroy objects
Post by Stefan Walter
how do I destroy objects in omniORB which are not longer required.
Can you clarify what you are talking about destroying? There are at
least two things you might mean:

1. On the client side, release the object reference.
2. On the server side, deactivate the object and delete the servant.

In CORBA, those two things are totally separate concerns. Client
object
references are reference counted, and the Echo_var holder
automatically
releases its reference when it goes out of scope.

The lifetime of server-side object activations is completely
unaffected
by whether any clients hold object references. If you want to get rid
of
the server-side objects, you must write server-side code to do so. It
is
common to define a destroy() method in your IDL, for example, so a
client can dispose of an object when it has finished with it. To
deactivate an object, you call deactivate_object on the POA it is
activated within.

In more complex situations, you might want to implement some sort of
evictor or timeout that automatically deactivates objects that are no
longer in use. It all depends upon what you want the semantics to be.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- duncan at grisby.org --
-- http://www.grisby.org --




__________________________________________
The content of this e-mail is confidential and restricted for the use of
the intended recipient only. If you are not the intended recipient
please inform the sender immediately and delete this e-mail and any
attachments. We cannot accept liability for any damage incurred as a
result of software viruses and advise that you carry out your own virus
checks before opening any attachment.

Der Inhalt dieses E-Mails ist vertraulich und f?r die alleinige
Verwendung durch den beabsichtigten Empf?nger bestimmt. Falls Sie nicht
der beabsichtigte Empf?nger sind, bitten wir Sie den Absender umgehend
zu informieren und dieses E-Mail samt angeschlossenen Dateien zu
l?schen. Wir k?nnen keine Haftung f?r allf?llige Sch?den ?bernehmen,
die aufgrund von Software-Viren entstehen, und empfehlen Ihnen, selbst
Virenpr?fungen durchzuf?hren, bevor Sie eine Anlage ?ffnen.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20130703/73e28d4e/attachment.html>
Loading...