Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: content/app/content_main_runner.cc

Issue 10239012: Route calls to tcmalloc MallocExtension through allocator agnostic interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: separate allocator_extension into own static library, add comments to allocator_extension.h Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698