summaryrefslogtreecommitdiffstats
path: root/third_party/tcmalloc
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-08 01:27:03 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-08 01:27:03 +0000
commit3422af1d763d8fe33d31863ff1bd1bfe103681a1 (patch)
tree2f3b0e0f3d0783ef6b0cd547e04c73314c0e2a30 /third_party/tcmalloc
parent82d9d3ac74211ae08a355a6184d156d0fd31f728 (diff)
downloadchromium_src-3422af1d763d8fe33d31863ff1bd1bfe103681a1.zip
chromium_src-3422af1d763d8fe33d31863ff1bd1bfe103681a1.tar.gz
chromium_src-3422af1d763d8fe33d31863ff1bd1bfe103681a1.tar.bz2
Enable memory profiler on Linux when TC_MALLOC is enabled.
Added a tc_malloc memory extension to get bytes allocated on current thread (GetBytesAllocatedOnCurrentThread API call). R=jam@chromium.org,jar@chromium.org BUG=139667 TEST=test about:profiler after setting the env variable CHROME_PROFILER_TIME=1. In about:profiler, it will show the memory allocated per thread. This change impacts linux only. This is same as the following previously approved CL. Added needed BASE_EXPORT for kAlternateProfilerTime and SetAlternateTimeSource. the https://chromiumcodereview.appspot.com/10820063/ Review URL: https://chromiumcodereview.appspot.com/10834199 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150477 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/tcmalloc')
-rw-r--r--third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h6
-rw-r--r--third_party/tcmalloc/chromium/src/malloc_extension.cc7
2 files changed, 11 insertions, 2 deletions
diff --git a/third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h b/third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h
index 5bee019..950b603 100644
--- a/third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h
+++ b/third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2005, Google Inc.
+// Copyright (c) 2012, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -307,6 +307,10 @@ class PERFTOOLS_DLL_DECL MallocExtension {
// malloc implementation during initialization.
static void Register(MallocExtension* implementation);
+ // On the current thread, return the total number of bytes allocated.
+ // (Currently only implemented in tcmalloc.)
+ static unsigned int GetBytesAllocatedOnCurrentThread();
+
// Returns detailed information about malloc's freelists. For each list,
// return a FreeListInfo:
struct FreeListInfo {
diff --git a/third_party/tcmalloc/chromium/src/malloc_extension.cc b/third_party/tcmalloc/chromium/src/malloc_extension.cc
index 2d6497f..fb30d39 100644
--- a/third_party/tcmalloc/chromium/src/malloc_extension.cc
+++ b/third_party/tcmalloc/chromium/src/malloc_extension.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2005, Google Inc.
+// Copyright (c) 2012, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -50,6 +50,7 @@
#include "gperftools/malloc_extension.h"
#include "gperftools/malloc_extension_c.h"
#include "maybe_threads.h"
+#include "thread_cache.h"
using STL_NAMESPACE::string;
using STL_NAMESPACE::vector;
@@ -220,6 +221,10 @@ void MallocExtension::Register(MallocExtension* implementation) {
}
}
+unsigned int MallocExtension::GetBytesAllocatedOnCurrentThread() {
+ return tcmalloc::ThreadCache::GetBytesAllocatedOnCurrentThread();
+}
+
// -----------------------------------------------------------------------
// Heap sampling support
// -----------------------------------------------------------------------