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.
This PR focuses on fixing the memory leaks that remained after addressing the ones fixed by introducing
Promise.race()
, which were surprisingly non-zero in number.Promise.race()
" implementation itself had a variation of the original leak, though it's super-understandable why it wasn't caught earlier. Specifically, the original version was tested by allocating bunches of objects which didn't have any references between them, so it was easy not to notice that there was (literally) one more than you'd expect when running the test to see if the new version leaked. In the case of this project, a single leak of the "wrong" race contender acts kind of like a trip-wire which then causes massive excess memory consumption (due to the nature of the links from eachLinkedEvent
to its next-event).LinkedEvent
which would then hold onto every subsequently-emitted event for the life of the process), it seemed worthwhile to work around the problem, which turned out not to be too awful to do. I left a big ole comment in the code explaining what's going on.