diff options
author | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-06 20:00:57 +0000 |
---|---|---|
committer | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-06 20:00:57 +0000 |
commit | 40175c86c04f00bc0822f90e51954f0714700143 (patch) | |
tree | cc3e89c379bae968fec3a4bb3543f3d992f28c81 /third_party/tcmalloc | |
parent | b77c8a8d7f6f02ba6f175babdd858ee29ed2744e (diff) | |
download | chromium_src-40175c86c04f00bc0822f90e51954f0714700143.zip chromium_src-40175c86c04f00bc0822f90e51954f0714700143.tar.gz chromium_src-40175c86c04f00bc0822f90e51954f0714700143.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.
Review URL: https://chromiumcodereview.appspot.com/10820063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150135 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/tcmalloc')
-rw-r--r-- | third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h | 6 | ||||
-rw-r--r-- | third_party/tcmalloc/chromium/src/malloc_extension.cc | 7 |
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 // ----------------------------------------------------------------------- |