Skip to content
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

Wrap memoized values in weak refs #846

Merged
merged 1 commit into from Mar 28, 2016

Conversation

Projects
None yet
1 participant
@ddfreyne
Copy link
Member

commented Mar 28, 2016

Memoized values only exist to speed up calculations, and are okay to be garbage-collected when memory pressure rises.

The Wrapper is necessary in order to let the value pointed to by the weak ref behave exactly as the calculation result. In particular, nil is troublesome as it requires syntactic support from Ruby to be handled properly, and weak refs to nil don’t behave the same as nil itself.

@ddfreyne ddfreyne merged commit ed8eac5 into master Mar 28, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ddfreyne ddfreyne deleted the weakref-memoize branch Mar 28, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.