Bug 1072903 - TraceLogger: Part 4: Free things accordingly, r=bbouvier
☠☠ backed out by b09069fd05ef ☠ ☠
authorHannes Verschore <hv1989@gmail.com>
Thu, 20 Nov 2014 17:44:00 +0100
changeset 216668 33167a292285ee51fe5a03b18de7345d2f07b87b
parent 216667 8b9390d62ecd27b2bd65b0301ddabac5cbaf0c9d
child 216669 8661c6e4fa51801b2fdca7ed6914df421f858a00
push id27858
push userkwierso@gmail.com
push dateFri, 21 Nov 2014 01:35:46 +0000
treeherdermozilla-central@6309710dd71d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1072903
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1072903 - TraceLogger: Part 4: Free things accordingly, r=bbouvier
js/src/vm/TraceLogging.cpp
js/src/vm/TraceLoggingTypes.h
--- a/js/src/vm/TraceLogging.cpp
+++ b/js/src/vm/TraceLogging.cpp
@@ -134,16 +134,21 @@ TraceLoggerThread::init()
 
     return true;
 }
 
 TraceLoggerThread::~TraceLoggerThread()
 {
     if (!failed)
         graph.log(events);
+
+    for (uint32_t i = 0; i < extraTextId.length(); i++) {
+        js_free(extraTextId[i]);
+    }
+    extraTextId.clear();
 }
 
 bool
 TraceLoggerThread::enable()
 {
     if (enabled > 0) {
         enabled++;
         return true;
@@ -258,18 +263,20 @@ TraceLoggerThread::createTextId(const ch
     size_t len = strlen(text);
     char *str = js_pod_malloc<char>(len + 1);
     if (!str)
         return TraceLogger_Error;
 
     DebugOnly<size_t> ret = JS_snprintf(str, len + 1, "%s", text);
     MOZ_ASSERT(ret == len);
 
-    if (!extraTextId.append(str))
+    if (!extraTextId.append(str)) {
+        js_free(str);
         return TraceLogger_Error;
+    }
 
     uint32_t textId = extraTextId.length() - 1 + TraceLogger_Last;
     if (!pointerMap.add(p, text, textId))
         return TraceLogger_Error;
 
     graph.addTextId(textId, text);
     return textId;
 }
@@ -301,18 +308,20 @@ TraceLoggerThread::createTextId(const ch
     size_t len = 7 + lenFilename + 1 + lenLineno + 1 + lenColno;
     char *str = js_pod_malloc<char>(len + 1);
     if (!str)
         return TraceLogger_Error;
 
     DebugOnly<size_t> ret = JS_snprintf(str, len + 1, "script %s:%u:%u", filename, lineno, colno);
     MOZ_ASSERT(ret == len);
 
-    if (!extraTextId.append(str))
+    if (!extraTextId.append(str)) {
+        js_free(str);
         return TraceLogger_Error;
+    }
 
     uint32_t textId = extraTextId.length() - 1 + TraceLogger_Last;
     if (!pointerMap.add(p, ptr, textId))
         return TraceLogger_Error;
 
     graph.addTextId(textId, str);
 
     return textId;
--- a/js/src/vm/TraceLoggingTypes.h
+++ b/js/src/vm/TraceLoggingTypes.h
@@ -132,16 +132,22 @@ class ContinuousSpace {
         size_ = 0;
         data_ = (T *) js_malloc(capacity_ * sizeof(T));
         if (!data_)
             return false;
 
         return true;
     }
 
+    ~ContinuousSpace()
+    {
+        js_free(data_);
+        data_ = nullptr;
+    }
+
     T *data() {
         return data_;
     }
 
     uint32_t capacity() {
         return capacity_;
     }