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

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: Refactored. Created 9 years 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
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 25bed9a4e087cf6814b57dc5b0a1fda071202d23..5f3a8e7f18518f7d948805feb42bf183b838b61f 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)");
//----------------------------------------------------------------------
@@ -175,6 +179,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
@@ -193,7 +198,11 @@ static char* DoGetHeapProfileLocked(char* buf, int buflen) {
if (FLAGS_mmap_profile) {
heap_profile->RefreshMMapData();
}
- bytes_written = heap_profile->FillOrderedProfile(buf, buflen - 1);
+ if (FLAGS_deep_heap_profile) {
+ bytes_written = deep_profile->FillOrderedProfile(buf, buflen - 1);
+ } else {
+ bytes_written = heap_profile->FillOrderedProfile(buf, buflen - 1);
Alexander Potapenko 2011/12/20 13:57:23 Does deep_profile replace heap_profile everywhere
Dai Mikurube (NOT FULLTIME) 2011/12/21 09:13:49 deep_profile does get information from heap_profil
+ }
if (FLAGS_mmap_profile) {
heap_profile->ClearMMapData();
}
@@ -457,6 +466,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)))
Alexander Potapenko 2011/12/20 13:57:23 I wouldn't have aligned the placement new argument
Dai Mikurube (NOT FULLTIME) 2011/12/21 09:13:49 It's the first time also for me to see this way.
+ 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.
@@ -498,6 +514,13 @@ extern "C" void HeapProfilerStop() {
RAW_CHECK(MallocHook::RemoveMunmapHook(&MunmapHook), "");
}
+ if (FLAGS_deep_heap_profile) {
+ // free deep memory profiler
+ deep_profile->~DeepHeapProfile();
+ ProfilerFree(deep_profile);
+ deep_profile = NULL;
+ }
+
// free profile
heap_profile->~HeapProfileTable();
ProfilerFree(heap_profile);

Powered by Google App Engine
This is Rietveld 408576698