From 50b6c01fb0ed1e95f6e0922d6c44ea01f482ae17 Mon Sep 17 00:00:00 2001 From: "evan@chromium.org" Date: Wed, 18 May 2011 20:37:47 +0000 Subject: memory: don't reserve trace events unless we're using tracing Even when TraceEvent is disabled, we still poke at it unconditionally via the tracing macros. The ctor would reserve 1024 TraceEvents, allocating ~100kb, and TraceEvents have a ctor that touch the newly-reserved memory, which means it's not just virtual address space, we actually were wasting 100kb per process. Fix it by only reserving space for the TraceEvents once tracing is enabled. (It would be nice if we could avoid paying for any of this stuff in the common case of not using tracing, but this fix is simple.) Review URL: http://codereview.chromium.org/7037034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85810 0039d316-1c4b-4281-b951-d872f2087c98 --- base/debug/trace_event.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'base') diff --git a/base/debug/trace_event.cc b/base/debug/trace_event.cc index 5a526f6..4a6cf1c 100644 --- a/base/debug/trace_event.cc +++ b/base/debug/trace_event.cc @@ -241,7 +241,6 @@ TraceLog* TraceLog::GetInstance() { TraceLog::TraceLog() : enabled_(false) { - logged_events_.reserve(1024); } TraceLog::~TraceLog() { @@ -285,6 +284,7 @@ void TraceLog::SetEnabled(bool enabled) { AutoLock lock(lock_); if (enabled == enabled_) return; + logged_events_.reserve(1024); enabled_ = enabled; for (int i = 0; i < g_category_index; i++) { //TODO(scheib): If changed to enable specific categories instead of all -- cgit v1.1