Browse Source

HPCC-13986 Valgrind reporting memory leaks re statistics

Statistic records being leaked when addStatistic or updateStatistic called.
This could accumulate into a significant leak over time particularly on THor.
Roxie is less affected since it is only an issue when queries are run via
workunit queue.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 10 years ago
parent
commit
da9eaddd6e
1 changed files with 5 additions and 2 deletions
  1. 5 2
      system/jlib/jstats.cpp

+ 5 - 2
system/jlib/jstats.cpp

@@ -1005,6 +1005,7 @@ public:
         {
             Statistic * next = Statistic::deserialize(in, version);
             stats.append(*next);
+            next->Release();
         }
 
         unsigned numChildren;
@@ -1108,7 +1109,8 @@ public:
 //other public interface functions
     void addStatistic(StatisticKind kind, unsigned __int64 value)
     {
-        stats.append(*new Statistic(kind, value));
+        Statistic s(kind, value);
+        stats.append(s);
     }
 
     void updateStatistic(StatisticKind kind, unsigned __int64 value, StatsMergeAction mergeAction)
@@ -1125,7 +1127,8 @@ public:
                 }
             }
         }
-        stats.append(*new Statistic(kind, value));
+        Statistic s(kind, value);
+        stats.append(s);
     }
 
     CStatisticCollection * ensureSubScope(const StatsScopeId & search, bool hasChildren)