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

Fix unintentional value retain #248

Merged
merged 2 commits into from
Nov 11, 2022
Merged

Fix unintentional value retain #248

merged 2 commits into from
Nov 11, 2022

Conversation

sorawee
Copy link
Collaborator

@sorawee sorawee commented Nov 10, 2022

To quote to the documentation of parameters
(https://docs.racket-lang.org/reference/parameters.html),

as far as the memory manager is concerned,
the value originally associated with a parameter through parameterize
remains reachable as long the continuation is reachable,
even if the parameter is mutated.

The parameter current-terms is initialized and/or parameterized to a strong hash, making it not possible to GC the hash. This PR fixes the issue by initializing and/or parameterizing to #f first, and then mutates the parameter to a desired value later.

Fixes #247

To quote to the documentation of parameters
(https://docs.racket-lang.org/reference/parameters.html),

> as far as the memory manager is concerned,
> the value originally associated with a parameter through parameterize
> remains reachable as long the continuation is reachable,
> even if the parameter is mutated.

The parameter current-terms is initialized and/or parameterized to a
strong hash, making it not possible to GC the hash.
This PR fixes the issue by initializing and/or parameterizing to #f
first, and then mutates the parameter to a desired value later.

Fixes emina#247
@sorawee
Copy link
Collaborator Author

sorawee commented Nov 10, 2022

By the way, thanks to @rocketnia who pointed me to the parameter caveat!

@rocketnia
Copy link

Glad it worked out! 😄

@emina emina merged commit d3c7abf into emina:master Nov 11, 2022
@emina
Copy link
Owner

emina commented Nov 11, 2022

Great catch; thanks!

@sorawee sorawee deleted the fix-247 branch November 11, 2022 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unintentional value retain
3 participants