[omniORB] basic parameter passing question
renny.koshy at rubixinfotech.com
renny.koshy at rubixinfotech.com
Wed Nov 30 11:18:35 GMT 2005
Anthony
>From what I understand, the answer is "Yes". When anything is "returned"
by a server, the client "owns" the object. I believe the way it's actually
done is that the server side "stubs" essentially take ownership of the
"thing" and free it up as soon as the data is marshalled and sent back to
the client.
In the way this following code works:
isdn::BChannelControlClient_var retval = bchan->getControl();
return retval._retn();
The _var makes a copy of the ref (if required) and when it is destructed
(goes out of scope), it removes that copy.
The problem with your first case is that you're making TWO copies of the
ref and the server side stub only takes ownership of one of the copies.
Regards,
Renny Koshy
President & CEO
--------------------------------------------
RUBIX Information Technologies, Inc.
www.rubixinfotech.com
Anthony Shipman
<A.Shipman at vortic
eresearchgroup.co To
m> omniORB-list at omniorb-support.com
Sent by: cc
omniorb-list-boun
ces at omniorb-suppo Subject
rt.com [SPAM] [omniORB] basic parameter
passing question
11/30/2005 03:32
AM
A server of mine has an object reference stored as:
isdn::BChannelControlClient_var ctlObj_;
isdn::BChannelControlClient_var&
BChannel::getControl()
{
return ctlObj_;
}
A method of an interface wants to return this object reference.
isdn::BChannelControlClient_ptr
Service_impl::new_client(...)
{
...
return isdn::BChannelControlClient::_duplicate(bchan->getControl());
}
The Michi+Henning book says that the caller of new_client() is responsible
for
releasing the returned object reference. This says to me that I must
duplicate the reference before returning it. Is this correct?
With omniORB 4.0.5 I find that there is a memory leak. I'm told that the
leak
goes away if I return the reference like this.
isdn::BChannelControlClient_var retval = bchan->getControl();
return retval._retn();
As far as I can tell this code should be exactly equivalent to the use of
duplicate. Does this make sense to anyone?
--
Anthony Shipman | Mamas don't let your babies
A.Shipman at vorticeresearchgroup.com | grow up to be outsourced.
_______________________________________________
omniORB-list mailing list
omniORB-list at omniorb-support.com
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
More information about the omniORB-list
mailing list