Index: third_party/tcmalloc/chromium/src/heap-profiler.cc |
diff --git a/third_party/tcmalloc/chromium/src/heap-profiler.cc b/third_party/tcmalloc/chromium/src/heap-profiler.cc |
index 1c5fcf088e297739303d400da5f3d198bff7087b..efddfaebe0560d9011509577094686f744dd099a 100644 |
--- a/third_party/tcmalloc/chromium/src/heap-profiler.cc |
+++ b/third_party/tcmalloc/chromium/src/heap-profiler.cc |
@@ -125,6 +125,11 @@ DEFINE_bool(only_mmap_profile, |
DEFINE_bool(deep_heap_profile, |
EnvToBool("DEEP_HEAP_PROFILE", false), |
"If heap-profiling is on, profile deeper (only on Linux)"); |
+#if defined(PROFILING_ALLOCATED_TYPE) |
+DEFINE_bool(heap_profile_dump_allocated_type, |
+ EnvToBool("HEAP_PROFILE_DUMP_ALLOCATED_TYPE", false), |
+ "If heap-profiling is on, dump allocated type statistics."); |
+#endif // PROFILING_ALLOCATED_TYPE |
//---------------------------------------------------------------------- |
@@ -305,6 +310,15 @@ static void DumpProfileLocked(const char* reason) { |
RawWrite(fd, profile, strlen(profile)); |
RawClose(fd); |
+#if defined(PROFILING_ALLOCATED_TYPE) |
+ if (FLAGS_heap_profile_dump_allocated_type) { |
+ snprintf(file_name, sizeof(file_name), "%s.%05d.%04d.type", |
+ filename_prefix, getpid(), dump_count); |
+ RAW_VLOG(0, "Dumping allocated type statistics to %s", file_name); |
+ heap_profile->DumpAllocatedTypeStatistics(file_name); |
+ } |
+#endif // PROFILING_ALLOCATED_TYPE |
+ |
dumping = false; |
} |