Skip to content

Commit

Permalink
Fix memory leak occurs every one second (#17516)
Browse files Browse the repository at this point in the history
* Fix memory leak occurs every one second

* Update src/lib/support/Pool.h

Co-authored-by: Boris Zbarsky <[email protected]>

Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Feb 16, 2024
1 parent ca979b1 commit 1963986
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);

// 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

0 comments on commit 1963986

Please sign in to comment.