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

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

Issue 8633006: Add HEAP_PROFILE_TIME_INTERVAL to dump heap profiles periodically in third_party/tcmalloc/chromium. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed. 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
« no previous file with comments | « no previous file | 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 445f53f50317d6a63285d55848bce3c7cf421b0c..794988d8f34560269d123da7674741203c9466b8 100644
--- a/third_party/tcmalloc/chromium/src/heap-profiler.cc
+++ b/third_party/tcmalloc/chromium/src/heap-profiler.cc
@@ -107,6 +107,10 @@ DEFINE_int64(heap_profile_inuse_interval,
"If non-zero, dump heap profiling information whenever "
"the high-water memory usage mark increases by the specified "
"number of bytes.");
+DEFINE_int64(heap_profile_sec_interval,
+ EnvToInt64("HEAP_PROFILE_TIME_INTERVAL", 0),
Alexander Potapenko 2011/12/20 13:26:04 Please name the variable accordingly, i.e. heap_pr
Dai Mikurube (NOT FULLTIME) 2011/12/21 05:40:56 Done.
+ "If non-zero, dump heap profiling information once every "
+ "specified number of seconds since the last dump.");
DEFINE_bool(mmap_log,
EnvToBool("HEAP_PROFILE_MMAP_LOG", false),
"Should mmap/munmap calls be logged?");
@@ -168,6 +172,7 @@ static int dump_count = 0; // How many dumps so far
static int64 last_dump_alloc = 0; // alloc_size when did we last dump
static int64 last_dump_free = 0; // free_size when did we last dump
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
@@ -284,6 +289,12 @@ static void MaybeDumpProfileLocked() {
snprintf(buf, sizeof(buf), "%"PRId64" MB currently in use",
inuse_bytes >> 20);
need_to_dump = true;
+ } else if (FLAGS_heap_profile_sec_interval > 0 &&
+ time(NULL) - last_dump_time >= FLAGS_heap_profile_sec_interval) {
Alexander Potapenko 2011/12/20 13:26:04 I think you'd better call time(NULL) only once.
Dai Mikurube (NOT FULLTIME) 2011/12/21 05:40:56 Done.
+ snprintf(buf, sizeof(buf), "%d sec since the last dump",
+ time(NULL) - last_dump_time);
+ need_to_dump = true;
+ last_dump_time = time(NULL);
}
if (need_to_dump) {
DumpProfileLocked(buf);
@@ -444,6 +455,7 @@ extern "C" void HeapProfilerStart(const char* prefix) {
last_dump_alloc = 0;
last_dump_free = 0;
high_water_mark = 0;
+ last_dump_time = 0;
// We do not reset dump_count so if the user does a sequence of
// HeapProfilerStart/HeapProfileStop, we will get a continuous
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698