[omniORB] problem with server memory deallocation
risc risc
riscman77 at gmail.com
Mon Apr 12 11:31:34 BST 2010
Hi All,
I have a problem with a server deallocation. I alloc a object in the server
routine and return the ogbect with obj._retn();
when the client destruct the orb, the object allocating in the server
routine is not be deallocated.
the idl is:
module test
{
interface p1
{
attribute string name;
};
interface p2
{
p1 function();
};
};
Server Routine relative P2 interface
test_p2_i::test_p2_i(){
// add extra constructor code here
cout<<"Constructor p2"<<endl;
}
test_p2_i::~test_p2_i(){
// add extra destructor code here
cout<<"destructor p2"<<endl;
}
// Methods corresponding to IDL attributes and operations
test::p1_ptr test_p2_i::function(){
// insert code here and remove the warning
test_p1_i * n=new test_p1_i;
------------------------------> HERE ALLOC THE OBJECT
n->name("ALEX");
test::p1_var ret=n->_this();
return ret._retn();
}
Server Routine relative P1 interface:
test_p1_i::test_p1_i(){
// add extra constructor code here
cout<<"constructor Call"<<endl;
}
test_p1_i::~test_p1_i(){
// add extra destructor code here
cout<<"Destructor Call"<<endl;
}
// Methods corresponding to IDL attributes and operations
void test_p1_i::nome(const char*){
// insert code here and remove the warning
}
char* test_p1_i::nome(){
// insert code here and remove the warning
}
CLIENT:
try {
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
if( argc != 2 ) {
cerr << "usage: eg2_clt <object reference>" << endl;
return 1;
}
CORBA::Object_var obj = orb->string_to_object(argv[1]);
test::p2_var p2=test::p2::_narrow(obj);
if( CORBA::is_nil(p2) ) {
cerr << "Can't narrow reference to type Echo (or it was nil)." <<
endl;
return 1;
}
test::p1_ptr l=p2->function();
l->nome();
CORBA::release(l);
orb->destroy();
AFTER the client run the destruct of p1 object is it not be called why?
there is a bug or i make an error on implementing server/client?
Thanks
R!SC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20100412/8d60c505/attachment.htm
More information about the omniORB-list
mailing list