mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
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
This commit is contained in:
parent
d85e538902
commit
4c5f3f0d60
@ -142,6 +142,7 @@ enum class SessionType {
|
||||
class KeyedHistogram {
|
||||
public:
|
||||
KeyedHistogram(HistogramID id, const HistogramInfo& info);
|
||||
~KeyedHistogram();
|
||||
nsresult GetHistogram(const nsCString& name, Histogram** histogram, bool subsession);
|
||||
Histogram* GetHistogram(const nsCString& name, bool subsession);
|
||||
uint32_t GetHistogramType() const { return mHistogramInfo.histogramType; }
|
||||
@ -642,6 +643,29 @@ KeyedHistogram::KeyedHistogram(HistogramID id, const HistogramInfo& info)
|
||||
{
|
||||
}
|
||||
|
||||
KeyedHistogram::~KeyedHistogram()
|
||||
{
|
||||
for (auto iter = mHistogramMap.Iter(); !iter.Done(); iter.Next()) {
|
||||
Histogram* h = iter.Get()->mData;
|
||||
if (h == gExpiredHistogram) {
|
||||
continue;
|
||||
}
|
||||
delete h;
|
||||
}
|
||||
mHistogramMap.Clear();
|
||||
|
||||
#if !defined(MOZ_WIDGET_ANDROID)
|
||||
for (auto iter = mSubsessionMap.Iter(); !iter.Done(); iter.Next()) {
|
||||
Histogram* h = iter.Get()->mData;
|
||||
if (h == gExpiredHistogram) {
|
||||
continue;
|
||||
}
|
||||
delete h;
|
||||
}
|
||||
mSubsessionMap.Clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
nsresult
|
||||
KeyedHistogram::GetHistogram(const nsCString& key, Histogram** histogram,
|
||||
bool subsession)
|
||||
@ -727,7 +751,11 @@ KeyedHistogram::Clear(bool onlySubsession)
|
||||
}
|
||||
#if !defined(MOZ_WIDGET_ANDROID)
|
||||
for (auto iter = mSubsessionMap.Iter(); !iter.Done(); iter.Next()) {
|
||||
iter.Get()->mData->Clear();
|
||||
Histogram* h = iter.Get()->mData;
|
||||
if (h == gExpiredHistogram) {
|
||||
continue;
|
||||
}
|
||||
delete h;
|
||||
}
|
||||
mSubsessionMap.Clear();
|
||||
if (onlySubsession) {
|
||||
@ -736,7 +764,11 @@ KeyedHistogram::Clear(bool onlySubsession)
|
||||
#endif
|
||||
|
||||
for (auto iter = mHistogramMap.Iter(); !iter.Done(); iter.Next()) {
|
||||
iter.Get()->mData->Clear();
|
||||
Histogram* h = iter.Get()->mData;
|
||||
if (h == gExpiredHistogram) {
|
||||
continue;
|
||||
}
|
||||
delete h;
|
||||
}
|
||||
mHistogramMap.Clear();
|
||||
}
|
||||
@ -1630,6 +1662,24 @@ void TelemetryHistogram::DeInitializeGlobalState()
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user