diff options
author | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-08 01:27:03 +0000 |
---|---|---|
committer | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-08 01:27:03 +0000 |
commit | 3422af1d763d8fe33d31863ff1bd1bfe103681a1 (patch) | |
tree | 2f3b0e0f3d0783ef6b0cd547e04c73314c0e2a30 /content/app | |
parent | 82d9d3ac74211ae08a355a6184d156d0fd31f728 (diff) | |
download | chromium_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 'content/app')
-rw-r--r-- | content/app/content_main_runner.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index 88a72e8..58dc14b 100644 --- a/content/app/content_main_runner.cc +++ b/content/app/content_main_runner.cc @@ -4,6 +4,8 @@ #include "content/public/app/content_main_runner.h" +#include <stdlib.h> + #include "base/allocator/allocator_extension.h" #include "base/at_exit.h" #include "base/command_line.h" @@ -17,6 +19,7 @@ #include "base/metrics/stats_table.h" #include "base/path_service.h" #include "base/process_util.h" +#include "base/profiler/alternate_timer.h" #include "base/stringprintf.h" #include "base/string_number_conversions.h" #include "content/browser/browser_main.h" @@ -450,6 +453,17 @@ static void ReleaseFreeMemoryThunk() { // On windows, we've already set these thunks up in _heap_init() base::allocator::SetGetStatsFunction(GetStatsThunk); base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); + + // Provide optional hook for monitoring allocation quantities on a + // per-thread basis. Only set the hook if the environment indicates this + // needs to be enabled. + const char* profiling = getenv(tracked_objects::kAlternateProfilerTime); + if (profiling && + (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) { + tracked_objects::SetAlternateTimeSource( + MallocExtension::GetBytesAllocatedOnCurrentThread, + tracked_objects::TIME_SOURCE_TYPE_TCMALLOC); + } #endif // On Android, |