Hacker News new | ask | show | jobs
by dzaima 607 days ago
nit - Rust does allow memory leaks in safe code. https://doc.rust-lang.org/std/mem/fn.forget.html#safety
2 comments

It's also possible to leak memory in languages with tracing garbage collection, just create a data structure that holds strong references to objects that are no longer needed, which commonly happens when using something like a HashMap as a cache without any kind of expiration.
Yes, memory leaks are rarer in Rust than in C, but they are an entirely different topic that 'unsafe' blocks.