Bug 1140059 - Stop leaking mThreadNameFilters in the profiler. (r=mstange)

This commit is contained in:
Shu-yu Guo 2015-03-06 17:58:26 -08:00
Родитель 1c4fd5e1a7
Коммит 06a50f8795
1 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -9,6 +9,7 @@
#include "platform.h"
#include "ProfileEntry.h"
#include "mozilla/Mutex.h"
#include "mozilla/Vector.h"
#include "IntelPowerGadget.h"
#ifdef MOZ_TASK_TRACER
#include "GeckoTaskTracer.h"
@ -23,15 +24,16 @@ hasFeature(const char** aFeatures, uint32_t aFeatureCount, const char* aFeature)
return false;
}
typedef mozilla::Vector<std::string> ThreadNameFilterList;
static bool
threadSelected(ThreadInfo* aInfo, char** aThreadNameFilters, uint32_t aFeatureCount) {
if (aFeatureCount == 0) {
threadSelected(ThreadInfo* aInfo, const ThreadNameFilterList &aThreadNameFilters) {
if (aThreadNameFilters.empty()) {
return true;
}
for (uint32_t i = 0; i < aFeatureCount; ++i) {
const char* filterPrefix = aThreadNameFilters[i];
if (strncmp(aInfo->Name(), filterPrefix, strlen(filterPrefix)) == 0) {
for (uint32_t i = 0; i < aThreadNameFilters.length(); ++i) {
if (aThreadNameFilters[i] == aInfo->Name()) {
return true;
}
}
@ -55,7 +57,6 @@ class TableTicker: public Sampler {
, mBuffer(new ProfileBuffer(aEntrySize))
, mSaveRequested(false)
, mUnwinderThread(false)
, mFilterCount(aFilterCount)
#if defined(XP_WIN)
, mIntelPowerGadget(nullptr)
#endif
@ -87,9 +88,9 @@ class TableTicker: public Sampler {
#endif
// Deep copy aThreadNameFilters
mThreadNameFilters = new char*[aFilterCount];
MOZ_ALWAYS_TRUE(mThreadNameFilters.resize(aFilterCount));
for (uint32_t i = 0; i < aFilterCount; ++i) {
mThreadNameFilters[i] = strdup(aThreadNameFilters[i]);
mThreadNameFilters[i] = aThreadNameFilters[i];
}
sStartTime = mozilla::TimeStamp::Now();
@ -150,7 +151,7 @@ class TableTicker: public Sampler {
return;
}
if (!threadSelected(aInfo, mThreadNameFilters, mFilterCount)) {
if (!threadSelected(aInfo, mThreadNameFilters)) {
return;
}
@ -243,8 +244,7 @@ protected:
// Keep the thread filter to check against new thread that
// are started while profiling
char** mThreadNameFilters;
uint32_t mFilterCount;
ThreadNameFilterList mThreadNameFilters;
bool mPrivacyMode;
bool mAddMainThreadIO;
bool mProfileMemory;