[omniORB] TypeCode_var equivalent memory leak

Alex Tingle alex.tingle at bronermetals.com
Tue Apr 13 17:27:30 BST 2004


Mike,

> (eventQueuesM[SourceQ].queue.back().type()->equivalent(Event.type())) )
> <<<<===== This is where it leaks

Any::type() manufactures a TypeCode_ptr for you - you are responsible 
for releasing it.
Try this instead:

   if( (!eventQueuesM[SourceQ].queue.empty()) )
   {
     CORBA::TypeCode_var backTc  
=eventQueuesM[SourceQ].queue.back().type();
     CORBA::TypeCode_var eventTc =Event.type();
     if( backTc->equivalent(eventTc) )
     {
       ...

regards,

-Alex Tingle

--
Dammit Jim, I'm a programmer... not a mind reader!

On 13 Apr 2004, at 16:05, Michael Shearer wrote:

> Hi!
>
> I'm having problems figuring out why the following bit of code leaks.
> For some reason, the TypeCode equivalent primitive seems to be
> allocating memory, is this correct behaviour?  Am I doing something
> wrong?
>
> I would appreciate any help!
>
> Thanks,
>
> Mike
>
> CORBA::Any* EventMgr_impl::pull( const CORBA::Any& Event,
> Event::queueName_t SourceQ )
> {
>         METHODTRACE( "CORBA::Any* EventMgr_impl::pull( const 
> CORBA::Any&
> Event, Event::queueName_t SourceQ )" );
>
>         CORBA::Any event;
>
>         if( (SourceQ < Event::MAX_EVENT_QUEUE) &&
>                   (SourceQ != Event::NULLQ) )
>         {
>                 if( (!eventQueuesM[SourceQ].queue.empty()) &&
>
> (eventQueuesM[SourceQ].queue.back().type()->equivalent(Event.type())) )
> <<<<===== This is where it leaks
>
>                 {
>                         eventQueuesM[SourceQ].notified = FALSE;
>                         event = eventQueuesM[SourceQ].queue.back();
>                         eventQueuesM[SourceQ].queue.pop_back();
>                         return new CORBA::Any(event);
>                 }
>                 else
>                         return NULL;
>         }
>         else
>         {
>                 LogError("Received pull for unknown queue.");
>                 throw Event::EventProxy::invalidQ();
>         }
> }
>
> Michael Shearer
> CVX SS7 Gateway (CSG) Engineer
> Aastra Telecom US, CVX Division
> 8 Federal Street
> Billerica, MA, USA, 01821-3570
> * Phone (978) 436-4248
> * Fax (978) 436-4233
> * Internet Mail mshearer at aastra.com
> * Web www.aastra.com
>
> <ATT145023.txt>




More information about the omniORB-list mailing list