Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Unified Diff: third_party/tcmalloc/chromium/src/heap-profiler.cc

Issue 8632007: A deeper heap profile dumper in third_party/tcmalloc/chromium. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: reflected the comments. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/tcmalloc/chromium/src/heap-profile-table.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 166afde643bc2a890848cda6af559eab1a508c77..85d1aadf7148b80f2a8b8d3c0096cf697dd5f81e 100644
--- a/third_party/tcmalloc/chromium/src/heap-profiler.cc
+++ b/third_party/tcmalloc/chromium/src/heap-profiler.cc
@@ -68,6 +68,7 @@
#include "base/spinlock.h"
#include "base/low_level_alloc.h"
#include "base/sysinfo.h" // for GetUniquePathFromEnv()
+#include "deep-heap-profile.h"
#include "heap-profile-table.h"
#include "memory_region_map.h"
@@ -121,6 +122,9 @@ DEFINE_bool(only_mmap_profile,
EnvToBool("HEAP_PROFILE_ONLY_MMAP", false),
"If heap-profiling is on, only profile mmap, mremap, and sbrk; "
"do not profile malloc/new/etc");
+DEFINE_bool(deep_heap_profile,
+ EnvToBool("DEEP_HEAP_PROFILE", false),
+ "If heap-profiling is on, profile deeper (only on Linux)");
//----------------------------------------------------------------------
@@ -179,6 +183,7 @@ static int64 high_water_mark = 0; // In-use-bytes at last high-water dump
static int64 last_dump_time = 0; // The time of the last dump
static HeapProfileTable* heap_profile = NULL; // the heap profile table
+static DeepHeapProfile* deep_profile = NULL; // deep memory profiler
//----------------------------------------------------------------------
// Profile generation
@@ -197,7 +202,11 @@ static char* DoGetHeapProfileLocked(char* buf, int buflen) {
if (FLAGS_mmap_profile) {
heap_profile->RefreshMMapData();
}
- bytes_written = heap_profile->FillOrderedProfile(buf, buflen - 1);
+ if (deep_profile) {
+ bytes_written = deep_profile->FillOrderedProfile(buf, buflen - 1);
+ } else {
+ bytes_written = heap_profile->FillOrderedProfile(buf, buflen - 1);
+ }
if (FLAGS_mmap_profile) {
heap_profile->ClearMMapData();
}
@@ -466,6 +475,13 @@ extern "C" void HeapProfilerStart(const char* prefix) {
high_water_mark = 0;
last_dump_time = 0;
+ if (FLAGS_deep_heap_profile) {
+ // Initialize deep memory profiler
+ RAW_VLOG(0, "[%d] Starting a deep memory profiler", getpid());
+ deep_profile = new(ProfilerMalloc(sizeof(DeepHeapProfile)))
+ DeepHeapProfile(heap_profile, prefix);
+ }
+
// We do not reset dump_count so if the user does a sequence of
// HeapProfilerStart/HeapProfileStop, we will get a continuous
// sequence of profiles.
@@ -507,6 +523,13 @@ extern "C" void HeapProfilerStop() {
RAW_CHECK(MallocHook::RemoveMunmapHook(&MunmapHook), "");
}
+ if (deep_profile) {
+ // free deep memory profiler
+ deep_profile->~DeepHeapProfile();
+ ProfilerFree(deep_profile);
+ deep_profile = NULL;
+ }
+
// free profile
heap_profile->~HeapProfileTable();
ProfilerFree(heap_profile);
« no previous file with comments | « third_party/tcmalloc/chromium/src/heap-profile-table.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698