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

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: 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..5040e13b032deb98cded4d2ddd09b038568b54ec 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 GetStatsThunk(char* buffer, int buffer_length) {
+ MallocExtension::instance()->GetStats(buffer, buffer_length);
+}
+
+static void ReleaseFreeMemoryThunk() {
+ MallocExtension::instance()->ReleaseFreeMemory();
+}
+#endif
+
+
#if defined(OS_WIN)
virtual int Initialize(HINSTANCE instance,
sandbox::SandboxInterfaceInfo* sandbox_info,
@@ -343,6 +359,10 @@ class ContentMainRunnerImpl : public content::ContentMainRunner {
#if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
// For tcmalloc, we need to tell it to behave like new.
tc_set_new_mode(1);
+
+ // On windows, we've already set these thunks up in _heap_init()
+ base::allocator::SetGetStatsFunction(GetStatsThunk);
+ base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk);
#endif
#if !defined(OS_ANDROID)
« no previous file with comments | « chrome/renderer/chrome_render_process_observer.cc ('k') | content/browser/tcmalloc_internals_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698