bug 1366294 - Part 12 - Clean up after onesself. r?gfritzsche
Without the StatisticsRecorder cleaning up after us we need to now manually
delete the Histograms we create.
MozReview-Commit-ID: 8jrPPBQmU0Z
--- a/toolkit/components/telemetry/TelemetryHistogram.cpp
+++ b/toolkit/components/telemetry/TelemetryHistogram.cpp
@@ -1625,16 +1625,34 @@ void TelemetryHistogram::InitializeGloba
void TelemetryHistogram::DeInitializeGlobalState()
{
StaticMutexAutoLock locker(gTelemetryHistogramMutex);
gCanRecordBase = false;
gCanRecordExtended = false;
gNameToHistogramIDMap.Clear();
gInitDone = false;
+
+ // FactoryGet `new`s Histograms for us, but requires us to manually delete.
+ for (size_t i = 0; i < HistogramCount; ++i) {
+ for (uint32_t process = 0; process < static_cast<uint32_t>(ProcessID::Count); ++process) {
+ delete gKeyedHistogramStorage[i][process];
+ gKeyedHistogramStorage[i][process] = nullptr;
+ for (uint32_t session = 0; session <
+ static_cast<uint32_t>(SessionType::Count); ++session) {
+ if (gHistogramStorage[i][process][session] == gExpiredHistogram) {
+ continue;
+ }
+ delete gHistogramStorage[i][process][session];
+ gHistogramStorage[i][process][session] = nullptr;
+ }
+ }
+ }
+ delete gExpiredHistogram;
+ gExpiredHistogram = nullptr;
}
#ifdef DEBUG
bool TelemetryHistogram::GlobalStateHasBeenInitialized() {
StaticMutexAutoLock locker(gTelemetryHistogramMutex);
return gInitDone;
}
#endif