From 5bcc5a9cfac0f2ddce9b0d20d5e5bbd525db8fa0 Mon Sep 17 00:00:00 2001 From: Hannes Verschore Date: Tue, 13 Jan 2015 13:37:27 +0100 Subject: [PATCH] Bug 1118686 - TraceLogger: Cap the maximum number of entries in the graph tree, r=bbouvier --- js/src/vm/TraceLoggingGraph.cpp | 2 +- js/src/vm/TraceLoggingGraph.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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;