[omniORB] object references management

Jorge García Velasco jgarcia@mabyc.com
Mon, 20 Mar 2000 15:33:10 +-100


Hi,

  I have a question about which is the correct method in omniORB to return and release object references.
 
  Currently I'm using omniORB3 prerelease 2 (snapshot omniORB3-20000316).   
 
  I've done an example where the client calls a remote method which returns an object reference. The client gets this reference and calls one of it's methods. After that, the client deallocates this reference.

  All runs right but I have a memory leak in the server side, it seems like the client cannot deallocates the remote reference correctly.

  Below there are some fragments of the client / server code.

  Is this code correct ?.


  Thanks in advanced.


    Jorge Garcia.

    R&D Software Engineer
    Mabyc, S.A.
    Barcelona (Spain)



SOURCE CODE
----------- 

libreria.idl
------------

#ifndef __LIBRERIA_IDL__
#define __LIBRERIA_IDL__

module Libreria
{
 interface Funciones
 {
  Funciones da_objeto();
  void show();
 };
};

#endif


servidor.cc
-----------
....
....

class Libreria_i : public virtual POA_Libreria::Funciones, 
                   public PortableServer::RefCountServantBase
{
 public:
  inline Libreria_i() {}  
  virtual ~Libreria_i() {}
  virtual Libreria::Funciones_ptr da_objeto();
  virtual void show();
};

void Libreria_i::show()
{
 cout << "Hello" << endl;
}

Libreria::Funciones_ptr Libreria_i::da_objeto()
{
 Libreria_i* new_servant=new Libreria_i;

 poa->activate_object(new_servant);

 return new_servant->_this();
}

....
....


cliente.cc
----------

....
....

Libreria::Funciones_ptr ret_val;

while(true)
{
 ret_val=e->da_objeto();

 ret_val->show();

 CORBA::release(ret_val);
}

....
....