[omniORB] omniORB memory leaks with MFC solved?

Guy Trudel gtrudel@mediatrix.com
Fri, 7 Jan 2000 11:15:01 -0500


It's not an omniorb with MFC leaks problem. It's just that some singleton
are not deleted before program termination. I build an OmniOrb 2.8 that
delete those singletons, calling orb::NP_destroy and
omni_thread::init_t::releaseStatic() (or add the call of
omni_thread::init_t::releaseStatic() to NP_destroy).

I just test the new build with very simple test case, my plan is just to use
this 'no leak' version in debug mode to detect my memory leaks. 

It won't delete leaks in omniDynamic280_rt.dll if you use it. If you don't
use TypeCode, Any, DynAny,etc you can compile without linking to
omniDynamic280_rt(d).dll see <RE: [omniORB] solution for problems compiling
projects using msdevstudio 6>


Here's the diff:

diff --recursive -u D:\OmniOrb2\omniORB_280/include/omnithread.h
D:\noLeak_OmniOrb2\omniORB_280/include/omnithread.h
--- D:\OmniOrb2\omniORB_280/include/omnithread.h	Wed Dec 22 14:08:56
1999
+++ D:\noLeak_OmniOrb2\omniORB_280/include/omnithread.h	Wed Dec 22 17:05:19
1999
@@ -508,6 +508,8 @@
 	static int count;
     public:
 	init_t(void);
+    
+    static void releaseStatic(void);
     };
 
     friend class init_t;


diff --recursive -u
D:\OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/corbaOrb.cc
D:\noLeak_OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/corbaOrb.cc
--- D:\OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/corbaOrb.cc	Wed
Sep 22 21:21:46 1999
+++ D:\noLeak_OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/corbaOrb.cc	Thu
Dec 23 12:45:45 1999
@@ -419,6 +419,10 @@
 
   delete orb;
   orb = 0;
+
+
+  CORBA::string_free(omniORB::serverName);
+  omni::myPrincipalID.replace(0, 0, NULL);
 }
 
 static
diff --recursive -u
D:\OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/objectRef.cc
D:\noLeak_OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/objectRef.cc
--- D:\OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/objectRef.cc	Mon
Aug 30 19:10:24 1999
+++ D:\noLeak_OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/objectRef.cc
Thu Dec 23 11:29:11 1999
@@ -988,6 +988,10 @@
 	p = next;
       }
     }
+  
+	delete omniObject::localObjectTable;
+	delete omniObject::localPyObjectTable;
+	delete omniObject::wrappedObjectTable;
   }
 };
 
diff --recursive -u
D:\OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/ropeFactory.cc
D:\noLeak_OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/ropeFactory.cc
--- D:\OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/ropeFactory.cc	Wed
Sep 22 21:21:46 1999
+++ D:\noLeak_OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/ropeFactory.cc
Thu Dec 23 12:08:35 1999
@@ -234,6 +234,16 @@
 
   void detach() {
     StrandScavenger::removeRopeFactories(globalOutgoingRopeFactories);
+	{
+		ropeFactory_iterator iterator( globalOutgoingRopeFactories);
+		delete iterator();
+	}
+
+
+	delete
omniORB::giopServerThreadWrapper::getGiopServerThreadWrapper();
+	delete globalOutgoingRopeFactories;
+
+	tcpSocketFactoryType::deleteSingleton();
   }
 };
 
diff --recursive -u
D:\OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/tcpSocket.cc
D:\noLeak_OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/tcpSocket.cc
--- D:\OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/tcpSocket.cc	Wed
Sep 22 21:21:48 1999
+++ D:\noLeak_OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/tcpSocket.cc
Thu Dec 23 12:01:45 1999
@@ -112,6 +112,12 @@
   }
 }
 
+void tcpSocketFactoryType::deleteSingleton()
+{
+	delete singleton;
+	singleton = 0;
+}
+
 tcpSocketFactoryType::tcpSocketFactoryType()
 {
 }

diff --recursive -u
D:\OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/tcpSocket.h
D:\noLeak_OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/tcpSocket.h
--- D:\OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/tcpSocket.h	Wed
Sep 22 21:21:48 1999
+++ D:\noLeak_OmniOrb2\omniORB_280/src/lib/omniORB2/orbcore/tcpSocket.h	Thu
Dec 23 11:58:59 1999
@@ -118,6 +118,8 @@
 
   friend class nobody;
 
+  static void deleteSingleton();
+
 private:
   tcpSocketFactoryType();
   ~tcpSocketFactoryType() {}  // Cannot delete a factory type instance

diff --recursive -u D:\OmniOrb2\omniORB_280/src/lib/omnithread/nt.cc
D:\noLeak_OmniOrb2\omniORB_280/src/lib/omnithread/nt.cc
--- D:\OmniOrb2\omniORB_280/src/lib/omnithread/nt.cc	Thu Sep 23 21:10:24
1999
+++ D:\noLeak_OmniOrb2\omniORB_280/src/lib/omnithread/nt.cc	Wed Dec 22
17:06:25 1999
@@ -417,6 +417,11 @@
 //
 // Initialisation function (gets called before any user code).
 //
+void omni_thread::init_t::releaseStatic(void)
+{
+	delete next_id_mutex; 
+	delete omni_thread::self(); 
+}
 
 omni_thread::init_t::init_t(void)
 {