[omniORB] memory management

ERIKSSON,TOBIAS (A-Sweden,ex1) tobias_eriksson@agilent.com
Fri, 22 Dec 2000 15:40:29 +0100


Hi
 I continously get a memory failure, SIGSEGV, but why?

What I have is basically this:

  SClass_impl *a1 = new SClass_impl();
  IClass_impl *a2 = new IClass_impl();

  //sequece seqv

  seqv.length( 2 );
  seqv[0] = SClass::_duplicate( a1->_this() );
  seqv[1] = IClass::_duplicate( a2->_this() );

  a1->dosomething();
  a2->domore();

  a1->_remove_ref();
  a2->_remove_ref();
 
  orb->destroy();

When the program is about to shut down, it executes the _remove_ref() lines.
I have a line in the destructor of SClass and IClass that prints that it is
beeing executed. But then the program dies a SIGSEGV is received. 
The seqv[0] is treated as _var and so when _duplicate() is called it will
increase the reference counting, and when it reaches the _remove_ref() it
will decrease the reference counting which now should be 1 again, but
something is not right here, cause as the sequence is deleted in the end it
will call CORBA::release( obj ) on the objects in the list (according to the
book I have) and thus the reference counting would now be 0, and the object
deleted. The line in my destructor is printed, but the application fails
with a SIGSEGV in the orb->destroy().
If someone has a comment on this that would be great, I'll read it when I
get back after new years eve.

Merry Christmas and a happy new year
 Tobias