Просмотр исходного кода

Merge pull request #11058 from richardkchapman/memleaks

HPCC-19513 Roxie does not free all static objects on closedown

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 7 лет назад
Родитель
Сommit
c2eb0d69d3

+ 13 - 1
roxie/ccd/ccdlistener.cpp

@@ -1850,6 +1850,18 @@ IArrayOf<IHpccProtocolListener> socketListeners;
 MapStringToMyClass<SharedObject> protocolDlls;
 MapStringToMyClass<IHpccProtocolPlugin> protocolPlugins;
 
+MODULE_INIT(INIT_PRIORITY_STANDARD)
+{
+    return true;
+}
+
+MODULE_EXIT()
+{
+    socketListeners.kill();
+    protocolPlugins.kill();
+    protocolDlls.kill();
+}
+
 IHpccProtocolPlugin *ensureProtocolPlugin(IHpccProtocolPluginContext &protocolCtx, const char *soname)
 {
     IHpccProtocolPlugin *plugin = protocolPlugins.getValue(soname ? soname : "native");
@@ -1858,7 +1870,7 @@ IHpccProtocolPlugin *ensureProtocolPlugin(IHpccProtocolPluginContext &protocolCt
     if (!soname)
     {
         Owned<IHpccProtocolPlugin> protocolPlugin = loadHpccProtocolPlugin(&protocolCtx, ensureLimiterFactory());
-        protocolPlugins.setValue("native", protocolPlugin.getLink());
+        protocolPlugins.setValue("native", protocolPlugin);
         return protocolPlugin.getClear();
     }
     Owned<SharedObject> so = new SharedObject();

+ 2 - 0
roxie/ccd/ccdmain.cpp

@@ -1218,6 +1218,7 @@ int STARTQUERY_API start_query(int argc, const char *argv[])
     globalPackageSetManager = NULL;
     stopDelayedReleaser();
     cleanupPlugins();
+    unloadHpccProtocolPlugin();
     closeMulticastSockets();
     releaseSlaveDynamicFileCache();
     releaseRoxieStateCache();
@@ -1225,6 +1226,7 @@ int STARTQUERY_API start_query(int argc, const char *argv[])
     setNodeCaching(false); // ditto
     perfMonHook.clear();
     strdup("Make sure leak checking is working");
+    roxiemem::releaseRoxieHeap();
     UseSysLogForOperatorMessages(false);
     ExitModuleObjects();
     releaseAtoms();

+ 5 - 0
roxie/ccd/ccdprotocol.cpp

@@ -2132,5 +2132,10 @@ extern IHpccProtocolPlugin *loadHpccProtocolPlugin(IHpccProtocolPluginContext *c
     return global.getLink();
 }
 
+extern void unloadHpccProtocolPlugin()
+{
+    queryLimiterFactory.clear();
+    global.clear();
+}
 
 //================================================================================================================================

+ 1 - 0
roxie/ccd/hpccprotocol.hpp

@@ -142,6 +142,7 @@ interface IHpccProtocolPlugin : extends IInterface
 };
 
 extern IHpccProtocolPlugin *loadHpccProtocolPlugin(IHpccProtocolPluginContext *ctx, IActiveQueryLimiterFactory *limiterFactory);
+extern void unloadHpccProtocolPlugin();
 typedef IHpccProtocolPlugin *(HpccProtocolInstallFunction)(IHpccProtocolPluginContext *ctx, IActiveQueryLimiterFactory *limiterFactory);
 
 

+ 2 - 0
rtl/eclrtl/eclrtl.cpp

@@ -33,6 +33,7 @@
 #include "unicode/ucol.h"
 #include "unicode/ustring.h"
 #include "unicode/ucnv.h"
+#include "unicode/uclean.h"
 #include "unicode/schriter.h"
 #include "unicode/regex.h"
 #include "unicode/normlzr.h"
@@ -267,6 +268,7 @@ MODULE_INIT(INIT_PRIORITY_STANDARD)
 MODULE_EXIT()
 {
     delete localeMap;
+    u_cleanup();
 }
 
 RTLLocale * queryRTLLocale(char const * locale)