Skip to content

Commit 5e5e1a6

Browse files
authored
fix(TaskManager): memory leak #4949 (#4950)
1 parent a9bc5e1 commit 5e5e1a6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Foundation/src/TaskManager.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,20 @@ bool TaskManager::start(Task* pTask)
6767
pTask->setState(Task::TASK_STARTING);
6868
try
6969
{
70+
{
71+
ScopedLockT lock(_mutex);
72+
_taskList.push_back(pAutoTask);
73+
}
7074
_threadPool.start(*pTask, pTask->name());
71-
ScopedLockT lock(_mutex);
72-
_taskList.push_back(pAutoTask);
7375
return true;
7476
}
7577
catch (...)
7678
{
7779
pTask->setOwner(nullptr);
80+
81+
ScopedLockT lock(_mutex);
82+
auto it = std::find(_taskList.begin(), _taskList.end(), pTask);
83+
if (it != _taskList.end()) _taskList.erase(it);
7884
throw;
7985
}
8086
}

0 commit comments

Comments
 (0)