fix(liveslots): avoid slotToVal memory leak for watched promises #10758
+55
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Liveslots has a bug (#10757) which leaks slotToVal entries when a tracked Promise is still being held in virtual data (e.g. a merely-virtual MapStore) at the time it becomes settled. This is triggered by
watchPromise
because of the order in which we attach two handlers: one which notices the resolution and is inhibited from deleting the slotToVal entry, and a second which removes the Promise from the (virtual)promiseRegistrations
collection (thus enabling the deletion). For any watched Promise that is resolved, we leave aslotToVal
entry (with an empty WeakRef) in RAM until the end of the incarnation.This PR does not fix the underlying bug, but it rearranges the handler order to avoid triggering it.
The attached unit test fails with the original handler order (
slotToVal.size
grows), and passes with the swapped order (slotToVal.size
remains constant).closes #10756
refs #10706