Commit d0bb789f authored by yangguo's avatar yangguo Committed by Commit bot

[profiler] fix memory leak for code entries for runtime callstats.

Track allocated code entries and delete at the end. This is what we
do in ProfileListener too.

R=alph@chromium.org, cbruni@chromium.org
BUG=v8:5753

Review-Url: https://codereview.chromium.org/2586923002
Cr-Commit-Position: refs/heads/master@{#41793}
parent d4493222
......@@ -649,10 +649,15 @@ ProfileGenerator::ProfileGenerator(Isolate* isolate,
DCHECK(counter->name());
auto entry = new CodeEntry(CodeEventListener::FUNCTION_TAG, counter->name(),
CodeEntry::kEmptyNamePrefix, "native V8Runtime");
code_entries_.push_back(entry);
code_map_.AddCode(reinterpret_cast<Address>(counter), entry, 1);
}
}
ProfileGenerator::~ProfileGenerator() {
for (auto code_entry : code_entries_) delete code_entry;
}
void ProfileGenerator::RecordTickSample(const TickSample& sample) {
std::vector<CodeEntry*> entries;
// Conservatively reserve space for stack frames + pc + function + vm-state.
......
......@@ -369,6 +369,7 @@ class CpuProfilesCollection {
class ProfileGenerator {
public:
ProfileGenerator(Isolate* isolate, CpuProfilesCollection* profiles);
~ProfileGenerator();
void RecordTickSample(const TickSample& sample);
......@@ -381,6 +382,7 @@ class ProfileGenerator {
Isolate* isolate_;
CpuProfilesCollection* profiles_;
CodeMap code_map_;
std::vector<CodeEntry*> code_entries_;
DISALLOW_COPY_AND_ASSIGN(ProfileGenerator);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment