Commit 3f5d39a1 authored by ulan's avatar ulan Committed by Commit bot

Fix memory-leak in default platform implementation of delayed tasks.

BUG=

Review URL: https://codereview.chromium.org/1221083004

Cr-Commit-Position: refs/heads/master@{#29446}
parent 55f27f77
......@@ -41,19 +41,24 @@ DefaultPlatform::~DefaultPlatform() {
base::LockGuard<base::Mutex> guard(&lock_);
queue_.Terminate();
if (initialized_) {
for (std::vector<WorkerThread*>::iterator i = thread_pool_.begin();
i != thread_pool_.end(); ++i) {
for (auto i = thread_pool_.begin(); i != thread_pool_.end(); ++i) {
delete *i;
}
}
for (std::map<v8::Isolate*, std::queue<Task*> >::iterator i =
main_thread_queue_.begin();
i != main_thread_queue_.end(); ++i) {
for (auto i = main_thread_queue_.begin(); i != main_thread_queue_.end();
++i) {
while (!i->second.empty()) {
delete i->second.front();
i->second.pop();
}
}
for (auto i = main_thread_delayed_queue_.begin();
i != main_thread_delayed_queue_.end(); ++i) {
while (!i->second.empty()) {
delete i->second.top().second;
i->second.pop();
}
}
}
......
......@@ -111,5 +111,21 @@ TEST(DefaultPlatformTest, PumpMessageLoopNoStarvation) {
EXPECT_TRUE(platform.PumpMessageLoop(isolate));
}
TEST(DefaultPlatformTest, PendingDelayedTasksAreDestroyedOnShutdown) {
InSequence s;
int dummy;
Isolate* isolate = reinterpret_cast<Isolate*>(&dummy);
{
DefaultPlatformWithMockTime platform;
StrictMock<MockTask>* task = new StrictMock<MockTask>;
platform.CallDelayedOnForegroundThread(isolate, task, 10);
EXPECT_CALL(*task, Die());
}
}
} // namespace platform
} // namespace v8
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