<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.17023" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=994241706-20042010><FONT face=Arial
color=#0000ff size=2>The call to _this() implicitly activates the object and
increments the reference count. As I already posted, you have to deactivate the
object in order to get it destructed properly.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=994241706-20042010><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=994241706-20042010><FONT face=Arial
color=#0000ff size=2>Wernke</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=994241706-20042010><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV><BR>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> omniorb-list-bounces@omniorb-support.com
[mailto:omniorb-list-bounces@omniorb-support.com] <B>On Behalf Of </B>risc
risc<BR><B>Sent:</B> 18 April 2010 11:47<BR><B>To:</B>
omniorb-list@omniorb-support.com<BR><B>Subject:</B> Re: [omniORB] problem with
server memory deallocation<BR></FONT><BR></DIV>
<DIV></DIV>Hi Duncan,<BR><BR>thanks for your reply. I see the leak because i
don't see the print of object destructor when the object is cancelled. I try
to post a minimal example<BR><BR>IDL FILE:
<DIV><BR><BR>module test<BR>{<BR> interface p1<BR> {
<BR> attribute string name;<BR>
};<BR> interface p2<BR> {<BR> p1
function();<BR> };<BR><BR>};<BR><BR><BR></DIV>CLIENT:
<DIV><BR><BR><BR> CORBA::ORB_var orb = CORBA::ORB_init(argc,
argv);<BR><BR><BR> if( argc != 2 )
{<BR> cerr << "usage: eg2_clt
<object reference>" << endl;<BR>
return 1;<BR> }<BR><BR> CORBA::Object_var
obj =
orb->string_to_object(argv[1]);<BR><BR><BR><BR></DIV>
test::p2_var pd=test::p2::_narrow(obj);<BR><BR> if(
CORBA::is_nil(pd) ) {
<DIV><BR> cerr << "Can't narrow
reference to type Echo (or it was nil)." <<
endl;<BR> return 1;<BR>
}<BR><BR><BR></DIV> test::p1_var l=pd->function();<BR>
<BR> l->name();<BR><BR> orb->destroy();<BR> <BR> }<BR><BR><BR><BR><BR><BR>SERVER:<BR><BR><BR>class
test_p1_i: public POA_test::p1 {<BR>private:<BR> <BR>public:<BR> //
standard constructor<BR> test_p1_i();<BR> virtual
~test_p1_i();<BR><BR> // methods corresponding to defined IDL attributes
and operations<BR> void name(const char*);<BR> char*
name();<BR><BR>};<BR><BR>//<BR>// Example implementational code for IDL
interface test::p1<BR>//
<DIV><BR>test_p1_i::test_p1_i(){<BR> // add extra constructor code
here<BR> cout<<"constructor
Call"<<endl;<BR>}<BR>test_p1_i::~test_p1_i(){<BR> // add extra
destructor code here<BR> cout<<"Destructor
Call"<<endl;<BR>}<BR>// Methods corresponding to IDL
attributes and operations<BR>void test_p1_i::nome(const char*){<BR> //
insert code here and remove the warning<BR> <BR>}<BR><BR></DIV>char*
test_p1_i::name(){
<DIV><BR> // insert code here and remove the
warning<BR><BR>}<BR><BR><BR><BR></DIV>class test_p2_i: public POA_test::p2
{<BR>private:<BR> <BR>public:<BR> // standard
constructor<BR> test_p2_i();<BR> virtual
~test_p2_i();<BR><BR> // methods corresponding to defined IDL attributes
and operations<BR> test::p1_ptr function();<BR><BR>};<BR><BR>//<BR>//
Example implementational code for IDL interface test::p2<BR>//
<DIV><BR>test_p2_i::test_p2_i(){<BR> <BR></DIV>
<DIV>cout<<"Constructor
p2"<<endl;<BR>}<BR>test_p2_i::~test_p2_i(){<BR> <BR></DIV>
<DIV> cout<<"destructor p2"<<endl;<BR>}<BR>//
Methods corresponding to IDL attributes and operations<BR><BR>test::p1_ptr
test_p2_i::function(){<BR> // insert code here and remove the
warning<BR></DIV>
<DIV> test_p1_i * n=new test_p1_i;<BR><BR></DIV>
n->name("Alfred");
<DIV><BR> <BR> test::p1_var ret=n->_this();<BR><BR></DIV>
<DIV> n->_remove_ref();<BR><BR> return
ret._retn();<BR>}<BR><BR><BR><BR></DIV>// End of example implementational
code<BR><BR><BR><BR>int main(int argc, char** argv)<BR>{<BR> try
{<BR> // Initialise the ORB.
<DIV><BR> CORBA::ORB_var orb = CORBA::ORB_init(argc,
argv);<BR><BR></DIV> // Obtain a reference to the root
POA.<BR> CORBA::Object_var obj = orb->resolve_initial_
<DIV class=gmail_quote>references("RootPOA");<BR> poa =
PortableServer::POA::_narrow(obj);<BR><BR> // We allocate
the objects on the heap. Since these are reference<BR>
// counted objects, they will be deleted by the POA when they are
no<BR> // longer needed.<BR>
test_p2_i* mytest_p2_i = new test_p2_i();<BR><BR><BR> //
Activate the objects. This tells the POA that the objects
are<BR> // ready to accept
requests.<BR> PortableServer::ObjectId_var
mytest_p2_iid =
poa->activate_object(mytest_p2_i);<BR><BR><BR> // Obtain
a reference to each object and output the stringified<BR> //
IOR to stdout<BR> {<BR>
// IDL interface: test::p2<BR> CORBA::Object_var
ref = mytest_p2_i->_this();<BR>
CORBA::String_var
sior(orb->object_to_string(ref));<BR>
std::cout << "IDL object test::p2 IOR = '" << (char*)sior <<
"'" << std::endl;<BR>
}<BR><BR><BR><BR> // Obtain a POAManager, and tell the POA
to start accepting<BR> // requests on its
objects.<BR> PortableServer::POAManager_var pman =
poa->the_POAManager();<BR>
pman->activate();<BR><BR>
orb->run();<BR> orb->destroy();<BR>
}<BR>....<BR><BR><BR>I See after the client make orb->destroy() the cout in
the P1 destroctor is not be called.<BR><BR>Thanks <BR>Best
Regards<BR></DIV><BR></BLOCKQUOTE></BODY></HTML>