You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Activity
asarhaddon commentedon Aug 26, 2026
Cloning the outer environment does not implement the desired behaviour, see #677.
Weak references could maybe fix variants of
(let* [f (fn* [] nil)] nil)but probably not variants of(let* [a (atom nil) l (list a)] (reset! a l)).rust: replace reference counting with garbage collection
rust: replace reference counting with garbage collection
rust: replace reference counting with garbage collection
rust: replace reference counting with garbage collection
rust: replace reference counting with garbage collection
asarhaddon commentedon Aug 28, 2026
Merge request #742 fixes this issue for rust.
The guide should definitively warn implementors against these two non-solutions #739.