Skip to content

Commit

Permalink
Fix memory leak occurs every one second
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Apr 19, 2022
1 parent 03ea72d commit 2ff8843
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib/support/Pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,17 @@ class HeapObjectPool : public internal::Statistics, public internal::PoolCommon<
internal::HeapObjectListNode * node = mObjects.FindNode(object);
if (node != nullptr)
{
// Note that the node is not removed here; that is deferred until the end of the next pool iteration.
node->mObject = nullptr;
Platform::Delete(object);

// Note need to be released immediately if not in the middle of iteration, otherwise cleanup is deferred
// until the end of the next pool iteration.
if (mObjects.mIterationDepth == 0)
{
node->Remove();
Platform::Delete(node);
}

DecreaseUsage();
}
}
Expand Down

0 comments on commit 2ff8843

Please sign in to comment.