diff --git a/js/src/vm/TraceLoggingGraph.cpp b/js/src/vm/TraceLoggingGraph.cpp index a7c339acc7fb..79ba8c189bf4 100644 --- a/js/src/vm/TraceLoggingGraph.cpp +++ b/js/src/vm/TraceLoggingGraph.cpp @@ -284,7 +284,7 @@ TraceLoggerGraph::startEvent(uint32_t id, uint64_t timestamp) return; if (!tree.hasSpaceForAdd()) { - if (!tree.ensureSpaceBeforeAdd()) { + if (tree.size() >= treeSizeFlushLimit() || !tree.ensureSpaceBeforeAdd()) { if (!flush()) { fprintf(stderr, "TraceLogging: Couldn't write the data to disk.\n"); enabled = 0; diff --git a/js/src/vm/TraceLoggingGraph.h b/js/src/vm/TraceLoggingGraph.h index 50a5edbe0e01..6896c00b39fb 100644 --- a/js/src/vm/TraceLoggingGraph.h +++ b/js/src/vm/TraceLoggingGraph.h @@ -202,6 +202,11 @@ class TraceLoggerGraph // Create a tree out of all the given events. void log(ContinuousSpace &events); + static size_t treeSizeFlushLimit() { + // Allow tree size to grow to 100MB. + return 100 * 1024 * 1024 / sizeof(TreeEntry); + } + private: bool failed; bool enabled;