Rust has an opt-in garbage collector as a library (https://docs.rs/gc/). I don't know how good it is, though.
The next option is to use reference counting by wrapping your data in Rc/Arc (depending on whether you need atomicity or not).
But that can still leak memory if you have cyclic data structures and can't break the cycle with Weak pointers.
At this point, what you need is a garbage collector.