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

Memory leaks in Rust implementation #709

Open
OgGhostJelly opened this issue Feb 26, 2025 · 0 comments
Open

Memory leaks in Rust implementation #709

OgGhostJelly opened this issue Feb 26, 2025 · 0 comments

Comments

@OgGhostJelly
Copy link

OgGhostJelly commented Feb 26, 2025

Circular references using Rc in Rust causes memory leaks! An environment can reference a function and a function can reference an environment, creating a circular reference. Possible fixes for the issue could be:

  • Cloning the outer environment when a function is created instead of keeping a reference to it, this could causes issues with referencing variables before assignment e.g if the environment gets mutated the functions own copy of the environment won't be changed.
  • Using a Weak reference instead of Rc, this could cause complications with function currying and referencing environments that have been dropped.
  • Implementing a garbage collector. The dumpster crate looks promising as a drop-in replacement for Rc.

I have already added the cloning outer reference method into my own mal rust implementation.

Or since the impls are mainly there for demonstration purposes it might not be worth the added complexity of fixing this issue.

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

No branches or pull requests

1 participant