[omniORB] Reference counting

Alex Shabarshoff shura@uc.ru
Fri, 14 Jul 2000 17:48:03 +0400


Hello all,

I have a question about reference counting and object deletition.

This is the interface file:

module dom
{
  interface Document
  {
   ///...
  };
};

And the part of program:

dom::Document_ptr MakeDocument() // actualy this is method of another
                                 // object
{
  POA_dom::Document_tie<DOM_Document> * result =
        new POA_dom::Document_tie<DOM_Document>( new DOM_Document() );
  dom::Document_ptr tempPtr = result->_this();
  result->_remove_ref(); // decrements refcount from 2 to 1
  return tempPtr;
}

...
{
  dom::Document_var doc = MakeDocument(); // i'm sure this is only
                                          // reference to dom::Document object
}
// should the servant object exist after this line?
...

Inspecting the code under debugger i found what _remove_ref() does not
even called at servant object POA_dom::Document_tie<DOM_Document> when
destructor  of  dom::Document_var is called. It looks like the servant
object  deleted  only  after  call to destroy(1,1) from POA. I'm using
omniORB3 pre3 and tie interfaces.

omniidl command line was:
omniidl -bcxx -Wbh=.h -Wbs=SK.cpp -DNO_NS_HACK -Wbtp -I../../../idl dom.idl

Best regards,  
  Alex Shabarshoff

Union Card Processing Company
Chief of Security Systems Development Department
Europay Security Supervisor