From dd891da04b9cc055b2ea9a4d98f2874bfca49f37 Mon Sep 17 00:00:00 2001 From: "dmikurube@chromium.org" Date: Mon, 10 Feb 2014 17:24:05 +0000 Subject: Invalidate MallocExtension::GetBytesAllocatedOnCurrentThread if !USE_TCMALLOC. This check is required to enable gperftools' heap-profiler without the tcmalloc memory allocator. See the bug for the details. BUG=341349 TEST=None Review URL: https://codereview.chromium.org/157233002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250130 0039d316-1c4b-4281-b951-d872f2087c98 --- .../tcmalloc/chromium/src/gperftools/malloc_extension.h | 5 ++++- third_party/tcmalloc/chromium/src/malloc_extension.cc | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'third_party') diff --git a/third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h b/third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h index 950b603..d1148de 100644 --- a/third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h +++ b/third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h @@ -308,7 +308,10 @@ class PERFTOOLS_DLL_DECL MallocExtension { static void Register(MallocExtension* implementation); // On the current thread, return the total number of bytes allocated. - // (Currently only implemented in tcmalloc.) + // This function is added in Chromium for profiling. + // Currently only implemented in tcmalloc. Returns 0 if tcmalloc is not used. + // Note that malloc_extension can be used without tcmalloc if gperftools' + // heap-profiler is enabled without the tcmalloc memory allocator. static unsigned int GetBytesAllocatedOnCurrentThread(); // Returns detailed information about malloc's freelists. For each list, diff --git a/third_party/tcmalloc/chromium/src/malloc_extension.cc b/third_party/tcmalloc/chromium/src/malloc_extension.cc index ad8fb8e..c143f13 100644 --- a/third_party/tcmalloc/chromium/src/malloc_extension.cc +++ b/third_party/tcmalloc/chromium/src/malloc_extension.cc @@ -50,7 +50,12 @@ #include "gperftools/malloc_extension.h" #include "gperftools/malloc_extension_c.h" #include "maybe_threads.h" + +#ifdef USE_TCMALLOC +// Note that malloc_extension can be used without tcmalloc if gperftools' +// heap-profiler is enabled without the tcmalloc memory allocator. #include "thread_cache.h" +#endif using STL_NAMESPACE::string; using STL_NAMESPACE::vector; @@ -222,7 +227,14 @@ void MallocExtension::Register(MallocExtension* implementation) { } unsigned int MallocExtension::GetBytesAllocatedOnCurrentThread() { + // This function is added in Chromium for profiling. +#ifdef USE_TCMALLOC + // Note that malloc_extension can be used without tcmalloc if gperftools' + // heap-profiler is enabled without the tcmalloc memory allocator. return tcmalloc::ThreadCache::GetBytesAllocatedOnCurrentThread(); +#else + return 0; +#endif } // ----------------------------------------------------------------------- -- cgit v1.1