diff options
author | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-10 17:24:05 +0000 |
---|---|---|
committer | dmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-10 17:24:05 +0000 |
commit | dd891da04b9cc055b2ea9a4d98f2874bfca49f37 (patch) | |
tree | 6b5d3510c1a6fcc900a4682192df436a01e64017 /third_party | |
parent | 230ea3b21a8daabde9b2e0dcd93dedb5b5a87003 (diff) | |
download | chromium_src-dd891da04b9cc055b2ea9a4d98f2874bfca49f37.zip chromium_src-dd891da04b9cc055b2ea9a4d98f2874bfca49f37.tar.gz chromium_src-dd891da04b9cc055b2ea9a4d98f2874bfca49f37.tar.bz2 |
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
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h | 5 | ||||
-rw-r--r-- | third_party/tcmalloc/chromium/src/malloc_extension.cc | 12 |
2 files changed, 16 insertions, 1 deletions
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 } // ----------------------------------------------------------------------- |