[omniORB] Releasing ties.

David Riddoch djr@uk.research.att.com
Mon, 7 Jun 1999 11:44:55 +0100 (GMT)


Hi,

An object will only be deleted if you have called the _dispose() method.
As you say, this is defined in _sk_Session -- but _tie_Session is derived
from this, and so inherits that member.

Note also that the object will not be deleted until there are no more
local references.

For example:

1   Session_i* myimpl = new Session_i();
2   _tie_Session<Session_i,1>* myobj = new
             _tie_Session<Session_i,1>(myimpl);
3   myobj->_obj_is_ready(boa);
4   Session_ptr myobjref = myobj->_this();
5   myobj->_dispose();
6   CORBA::release(myobjref);

<myimpl> is not deleted until line 6. If either line 5 or line 6 had been
omitted, then <myimpl> would never have been deleted.

Hope that helps,
David


On Tue, 1 Jun 1999, PJ McKenna wrote:

> Folks,
>   Say some optimist was fiddling around with tie-based implementations and
> was trying to release an object.
> 
>   Here's the code to get a "Session" object :
> 
>   	Session *GetSession() {
> 		Session_i *myimpl = new Session_i();
> 		_tie_Session<Session_i,1> *myobj = new
> _tie_Session<Session_i,1>(myimpl);
> 		myobj->_obj_is_ready(boa);
> 		Session_ptr myobjRef = myobj->_this();
> 		if (!bindObjectToName(orb,myobjRef, "Session")) {
> 			return Session::_nil();
> 		}
> 		return myobj;
> 	};
> 
> 
>   and here's the code to release it :
> 
> 	void ReleaseSession ( Session_ptr  ToRelease ) {
> 		CORBA::release(ToRelease);
> 	};
> 
>   When ReleaseSession is called, "CORBA::release(ToRelease)" causes the
> reference count of ToRelease to drop from 2 to 1.  At some point in the
> skeleton code this drops to 0.
>   My understanding of how this should work is that if the second parameter
> to "_tie_Session<Session_i,1>" is 1 (true) then when the reference count
> hits 0 the implementation object (myimpl) should be destroyed.  However, the
> Session object has a (virtual) destructor which is never called.
>   I know that a _dispose() method exists for _sk_Session - derived objects
> but I can't find one for the tie approach.
>   Anyone willing to give me some pointers?
>   
>   - P.J. Mc Kenna
> 
>