Index: content/app/content_main_runner.cc |
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc |
index 4f286fd71fa58df306c48459f8ee4a46d4043585..6af508c4b1bc66764bcc44f251544c445d0eff40 100644 |
--- a/content/app/content_main_runner.cc |
+++ b/content/app/content_main_runner.cc |
@@ -4,6 +4,7 @@ |
#include "content/public/app/content_main_runner.h" |
+#include "base/allocator/allocator_extension.h" |
#include "base/at_exit.h" |
#include "base/command_line.h" |
#include "base/debug/debugger.h" |
@@ -37,6 +38,10 @@ |
#include "ui/base/win/dpi.h" |
#include "webkit/glue/webkit_glue.h" |
+#if defined(USE_TCMALLOC) |
+#include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" |
+#endif |
+ |
#if defined(OS_WIN) |
#include <atlbase.h> |
#include <atlapp.h> |
@@ -314,6 +319,17 @@ class ContentMainRunnerImpl : public content::ContentMainRunner { |
Shutdown(); |
} |
+#if defined(USE_TCMALLOC) |
+static void get_stats_thunk(char* buffer, int buffer_length) { |
jam
2012/04/26 21:28:20
nit: chrome style is GetStatsThunk. also below
|
+ MallocExtension::instance()->GetStats(buffer, buffer_length); |
jam
2012/04/26 21:28:20
nit: 2 spaces.. also below
|
+} |
+ |
+static void release_free_memory_thunk() { |
+ MallocExtension::instance()->ReleaseFreeMemory(); |
+} |
+#endif |
+ |
+ |
#if defined(OS_WIN) |
virtual int Initialize(HINSTANCE instance, |
sandbox::SandboxInterfaceInfo* sandbox_info, |
@@ -345,6 +361,12 @@ class ContentMainRunnerImpl : public content::ContentMainRunner { |
tc_set_new_mode(1); |
#endif |
+ // On windows, we've already set these thunks up in _heap_init() |
+#if !defined(OS_WIN) && defined(USE_TCMALLOC) |
jam
2012/04/26 21:28:20
nit: if you don't want windows, then move this up
|
+ base::allocator::SetGetStatsFunction(get_stats_thunk); |
+ base::allocator::SetReleaseFreeMemoryFunction(release_free_memory_thunk); |
+#endif |
+ |
#if !defined(OS_ANDROID) |
// Set C library locale to make sure CommandLine can parse argument values |
// in correct encoding. |