-
Notifications
You must be signed in to change notification settings - Fork 0
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 leaks for token composition #2
Comments
I suspect this is a pretty common case. (in my travels, it appears to be) |
Actually the The real problem is when the composed token is does not get cancelled for a long time and does have no handlers (that do anything) registered. Some of their short-lived source tokens might even have been garbage-collected already, but they are still registered on some long-lived root token. In that case, we would want the single dependency to be collapsed, and the reference from the root to the composed token to be removed. |
@stefanpenner Yeah, in general they always form tree-like dependency structures (or actually, a multitree), but they usually have a constant-bounded depth, right? So if we can keep the width (number of children, i.e. handlers) of each node constant at least, we should achieve overall constant memory. Maybe you can share some examples where a large number of tokens is composed from a long-living one? |
@bergus would love to respond with some examples, but currently tied up with other stuff. If i don't respond by this upcoming monday, please feel free to pester me :) |
@stefanpenner Seems the time for pestering has come :-) Would you like a daily interval of inquiries? |
See the case made by @stefanpenner in tc39/proposal-cancelable-promises#52
In many situations, a long-lived cancellation token (passed in by the caller) is combined with a short-lived token, e.g. in the "last" example or for a timeout:
When the action is long over, and the combined token is no longer relevant to anyone, the
token
still holds are reference to it.Todo:
The text was updated successfully, but these errors were encountered: