-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
WeakMap w/ frozen keys and garbage collection #134
Labels
Comments
Thanks for the proposal. Makes sense, perfect solution.
It's required some additional work for prevent side effects, but, I think, I will take it. |
|
zloirock
added a commit
that referenced
this issue
Nov 22, 2015
zloirock
added a commit
that referenced
this issue
Nov 23, 2015
Available in 2.0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks like the current implementation uses a central store when a frozen key is used. This would mean that the keys would never be garbage collected, correct?
I was looking at another WeakMap implementation here: https://github.com/drses/weak-map
It overrides Object.freeze like this (as well as seal and preventExtensions):
This allows it to put a key-store on an object just before it is frozen to give it the opportunity to be used in a weak collection.
This approach may be a bit iffy. The drawbacks are 1) every frozen object gets an object added to it whether it's used or not, and 2) if an object is frozen before the freeze method is wrapped it won't work. But a huge pro to this approach is keys are garbage collected.
The text was updated successfully, but these errors were encountered: