Skip to content

Commit 525b396

Browse files
psmarshallCommit Bot
authored andcommitted
[cpu-profiler] Fix a leak caused by re-logging existing functions.
Don't re-log all existing functions during StartProcessorIfNotStarted(). They will already be in the CodeMap attached to the ProfileGenerator and re-logging them causes leaks. See the linked bug for more details. Bug: v8:8253 Change-Id: Ibb1a1ab2431c588e8c3a3a9ff714767cdf61a88e Reviewed-on: https://chromium-review.googlesource.com/1256763 Commit-Queue: Peter Marshall <[email protected]> Reviewed-by: Yang Guo <[email protected]> Cr-Commit-Position: refs/heads/master@{#56336}
1 parent aabed21 commit 525b396

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/profiler/cpu-profiler.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,11 @@ void CpuProfiler::StartProcessorIfNotStarted() {
368368
// Disable logging when using the new implementation.
369369
saved_is_logging_ = logger->is_logging_;
370370
logger->is_logging_ = false;
371+
372+
bool codemap_needs_initialization = false;
371373
if (!generator_) {
372374
generator_.reset(new ProfileGenerator(profiles_.get()));
375+
codemap_needs_initialization = true;
373376
CreateEntriesForRuntimeCallStats();
374377
}
375378
processor_.reset(new ProfilerEventsProcessor(isolate_, generator_.get(),
@@ -382,12 +385,14 @@ void CpuProfiler::StartProcessorIfNotStarted() {
382385
isolate_->set_is_profiling(true);
383386
// Enumerate stuff we already have in the heap.
384387
DCHECK(isolate_->heap()->HasBeenSetUp());
385-
if (!FLAG_prof_browser_mode) {
386-
logger->LogCodeObjects();
388+
if (codemap_needs_initialization) {
389+
if (!FLAG_prof_browser_mode) {
390+
logger->LogCodeObjects();
391+
}
392+
logger->LogCompiledFunctions();
393+
logger->LogAccessorCallbacks();
394+
LogBuiltins();
387395
}
388-
logger->LogCompiledFunctions();
389-
logger->LogAccessorCallbacks();
390-
LogBuiltins();
391396
// Enable stack sampling.
392397
processor_->AddCurrentStack(isolate_);
393398
processor_->StartSynchronously();

0 commit comments

Comments
 (0)