[omniORB] DynamicAny memory leak

Sampo Ahokas sampo.ahokas at openttcn.fi
Mon Jan 12 18:04:04 GMT 2009


Dear all,

I have been working on a project that uses DII, DSI and DynamicAny 
extensively, and it appears that there may be some memory leaks (or I'm 
doing things incorrectly, of course...). Setting the members/elements of 
DynStruct and DynSequence as DynAny seems to cause a leak.

DynStruct leak details:

DynStructImpl constructor calls setNumComponents(), which causes 
elements of pd_components to be initialized with initial values.
DynStructImpl::set_members_as_dyn_any()  then just assigns the new value 
to pd_components[i], leaking the initial values.

DynSequence leak details:

DynSequenceImpl::set_elements_as_dyn_any(const DynamicAny::DynAnySeq& 
as) calls setNumComponents(), and also
assigns the new values to pd_components[i], causing the initial values 
constructed by setNumComponents() to be leaked.


Similarly, DynArrayImpl::set_elements_as_dyn_any() might contain the 
same leak, but I haven't tried it as I'm not using it.
Attached is a patch that seems to fix the issue here.


Best regards,
Sampo Ahokas
OpenTTCN Ltd

-------------- next part --------------
--- omniORB-4.1.3-clean/src/lib/omniORB/dynamic/dynAny.cc	2008-09-16 12:24:08.000000000 +0300
+++ omniORB-4.1.3/src/lib/omniORB/dynamic/dynAny.cc	2009-01-12 17:32:27.000000000 +0200
@@ -2719,6 +2719,13 @@
       daib = ToDynAnyImplBase(newda);
     }
     daib->attach();
+
+    if(pd_components[i])
+    {
+        pd_components[i]->detach();
+        pd_components[i]->_NP_decrRefCount();
+    }
+
     pd_components[i] = daib;
   }
   pd_curr_index = (pd_n_components == 0) ? -1 : 0;
@@ -4415,6 +4422,13 @@
       daib = ToDynAnyImplBase(newda);
     }
     daib->attach();
+
+    if(pd_components[i])
+    {
+        pd_components[i]->detach();
+        pd_components[i]->_NP_decrRefCount();
+    }
+
     pd_components[i] = daib;
   }
 }


More information about the omniORB-list mailing list