Преглед на файлове

Merge pull request #8864 from ghalliday/issue15847

HPCC-15847 Add --releasemem option to aid catching memory leaks

Reviewed-By: Jamie Noss <james.noss@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman преди 9 години
родител
ревизия
35b0d310eb
променени са 2 файла, в които са добавени 16 реда и са изтрити 8 реда
  1. 15 8
      ecl/eclcc/eclcc.cpp
  2. 1 0
      ecl/eclcc/eclcc.hpp

+ 15 - 8
ecl/eclcc/eclcc.cpp

@@ -71,8 +71,8 @@
 
 //=========================================================================================
 
-//The following flag could be used not free items to speed up closedown
-static bool optDebugMemLeak = false;
+//The following flag is used to speed up closedown by not freeing items
+static bool optReleaseAllMemory = false;
 
 #if defined(_WIN32) && defined(_DEBUG)
 static HANDLE leakHandle;
@@ -374,11 +374,13 @@ protected:
     bool logTimings;
     bool optArchive;
     bool optCheckEclVersion;
+    bool optDebugMemLeak = false;
     bool optEvaluateResult;
     bool optGenerateMeta;
     bool optGenerateDepend;
     bool optIncludeMeta;
     bool optKeywords;
+    bool optLeakCheck = false;
     bool optWorkUnit;
     bool optNoCompile;
     bool optNoLogFile;
@@ -483,12 +485,13 @@ int main(int argc, const char *argv[])
 
     unsigned exitCode = doMain(argc, argv);
 
-#ifndef _DEBUG
-    //In release mode exit without calling all the clean up code.
-    //It is faster, and it helps avoids potential crashes if there are active objects which depend on objects in file hook dlls.
-    fflush(NULL);
-    _exit(exitCode);
-#endif
+    if (!optReleaseAllMemory)
+    {
+        //In release mode exit without calling all the clean up code.
+        //It is faster, and it helps avoids potential crashes if there are active objects which depend on objects in file hook dlls.
+        fflush(NULL);
+        _exit(exitCode);
+    }
 
     releaseAtoms();
     ClearTypeCache();   // Clear this cache before the file hooks are unloaded
@@ -2027,6 +2030,9 @@ int EclCC::parseCommandLineOptions(int argc, const char* argv[])
         else if (iter.matchFlag(optKeywords, "--keywords"))
         {
         }
+        else if (iter.matchFlag(optLeakCheck, "--leakcheck"))
+        {
+        }
         else if (iter.matchFlag(tempArg, "-L"))
         {
             libraryPaths.append(tempArg);
@@ -2205,6 +2211,7 @@ int EclCC::parseCommandLineOptions(int argc, const char* argv[])
     if (optArchive || optWorkUnit || optGenerateMeta || optGenerateDepend || optShowPaths)
         optNoCompile = true;
 
+    optReleaseAllMemory = optDebugMemLeak || optLeakCheck;
     loadManifestOptions();
 
     if (inputFileNames.ordinality() == 0 && !optKeywords)

+ 1 - 0
ecl/eclcc/eclcc.hpp

@@ -82,6 +82,7 @@ const char * const helpText[] = {
     "    -help -v      Display verbose help message",
     "!   -internal     Run internal tests",
     "?!  -legacy       Use legacy import and when semantics (deprecated)",
+    "!   --leakcheck   Clean up memory since checking for memory leaks",
     "!   --keywords    Outputs the list of ECL reserved words to stdout (XML format)",
     "!   -legacyimport Use legacy import semantics (deprecated)",
     "!   -legacywhen   Use legacy when/side-effects semantics (deprecated)",