Reference Cycle is a phenomenon in Rust when the reference count from #202206221720 can’t go down to 0 because references are referring or pointing to each other. Since the reference count of Rc<T>
is never going to be 0, it will not be clean up by Rust in runtime, in turn cause memory leak (unused memory). This is quite common when the codebase use 202206232210# with a combination of Rc<T>
(in the form of RefCell<Rc<T>>
).
Suggested solutions from the official Rust book is to detect it with automated #test, code review or data structure reorganisation to either express ownership (avoid RefCell<T>
at all cost) or not at all (use 202206251329# instead of Rc<T>
).