[omniORB] Reference count with tie implementation

Glenn A. Hochberg ghochberg@att.com
Wed, 13 Sep 2000 09:46:37 -0400


There are some discussions related to this in the archives.  First off, an
object reference is a separate object from the servant, and releasing it
(which means it will be deleted when the ref count goes to zero) will have
no impact on existence of the servant.

See the following for some relevant discussion:
http://www.uk.research.att.com/omniORB/archives/2000-07/0125.html
http://www.uk.research.att.com/omniORB/archives/2000-07/0103.html

    -Glenn

R.vd.Leek@fokkerspace.nl wrote:

> Hate to bother you with this general CORBA question, hoping for some
> help though...
>
> -- I've got the following server implementation:
>
> class MiTest_i {
> public:
>         inline MiTest_i() { cout << "object created" << endl; }
>         virtual ~MiTest_i() { cout << "object deleted" << endl; }
>         virtual void ping () {};
> };
>
> struct Node {
>         Node (MiTest_ptr ref, Node* n) : objref(ref), next(n) {};
>         MiTest_ptr objref;
>         Node* next;
> };
>
> class MiTestFactory_i {
> public:
>         inline MiTestFactory_i() : head(NULL) {}
>         virtual ~MiTestFactory_i() {}
>
>         virtual MiTest_ptr factorize () {
>                 MiTest_i* mi_test_impl = new MiTest_i();
>                 POA_MiTest_tie<MiTest_i>* mi_test =
>                         new POA_MiTest_tie<MiTest_i>(mi_test_impl);
>                 head = new Node(mi_test->_this(), head);
>                 return mi_test->_this();
>         }
>
>         virtual void destroyAllObjects () {
>                 while (head != NULL) {
>                         CORBA::release(head->objref);
>                         Node *tmp = head;
>                         head = head->next;
>                         delete tmp;
>                 }
>         }
> private:
>         Node* head;
> };
>
> -- and the following client implementation:
>
>                 MiTestFactory_var MiTestFactoryRef =
>                         MiTestFactory::_narrow(obj);
>
>                 cout << "creating " << NR_SERVER_OBJECTS <<
>                         " server objects..." << endl;
>                 MiTest_var servers[NR_SERVER_OBJECTS];
>                 for (int i=0; i<NR_SERVER_OBJECTS; i++)
>                         servers[i] = MiTestFactoryRef->factorize();
>                 // ....
>
>                 MiTestFactoryRef->destroyAllObjects();
>
> --
>
> The problem is that a release in the destroyAllObjects() method doesn't
> delete the MiTest objects (the destructor isn't called) and thus my
> application is leaking...
>
> Any help is appreciated, TIA
>
> rob.
> --
> Rob van der Leek
> Fokker Space b.v.
> Remote Sensing Group
> e-mail: r.vd.leek@fokkerspace.nl
> tel.: +31-(0)71-5245531

--
Glenn A. Hochberg  | "Any activity becomes creative when the doer
AT&T Labs          |  cares about doing it right, or doing it better."
ghochberg@att.com  |      -John Updike