Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak occurs every one second #17516

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

// The node needs to be released immediately if we are not in the middle of iteration.
// Otherwise cleanup is deferred until all iteration on this pool completes and it's safe to release nodes.
if (mObjects.mIterationDepth == 0)
{
node->Remove();
Platform::Delete(node);
}

DecreaseUsage();
}
}
Expand Down