Bug 1698524: Clear profiler memory counter on re-enabling of the profiler r=gerald

Differential Revision: https://phabricator.services.mozilla.com/D108447
This commit is contained in:
Randell Jesup 2021-04-07 15:46:16 +00:00
parent 09ab7490d6
commit ded16fcdaa
2 changed files with 10 additions and 0 deletions

View File

@ -547,6 +547,8 @@ void install_memory_hooks() {
// Also initialize the ThreadIntercept, even if native allocation tracking
// won't be turned on. This way the TLS will be initialized.
ThreadIntercept::Init();
} else {
sCounter->Clear();
}
jemalloc_replace_dynamic(replace_init);
}

View File

@ -110,6 +110,14 @@ class BaseProfilerCount {
# endif
}
void Clear() {
*mCounter = 0;
// We don't reset *mNumber or mPrevNumber. We encode numbers as
// positive deltas, and currently we only care about the deltas (for
// e.g. heatmaps). If we ever need to clear mNumber as well, we can an
// alternative method (Reset()) to do so.
}
// We don't define ++ and Add() here, since the static defines directly
// increment the atomic counters, and the subclasses implement ++ and
// Add() directly.