<div class="gmail_quote"><br><br>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 class="im">
<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 class="im"><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 class="im"><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 class="im">
<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 class="im"><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 class="im"><br>test_p2_i::test_p2_i(){<br> <br></div><div class="im">cout<<"Constructor p2"<<endl;<br>
}<br>test_p2_i::~test_p2_i(){<br>
<br></div><div class="im"> 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 class="im"> test_p1_i * n=new test_p1_i;<br>
<br></div> n->name("Alfred");<div class="im"><br> <br> test::p1_var ret=n->_this();<br><br></div><div class="im"> 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 class="im"><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_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><br><div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><font color="#888888"><br>
<br>
</font></blockquote></div></div></div><br>
</div><br>