4 ms·
The Rust compiler specifically aims to make it impossible to have segfaults, memory leaks, and data races — so to say unsafe code “is in fact checked” is at lea
by electrograv 9y ago
The Rust compiler specifically aims to make it impossible to have segfaults, memory leaks, and data races — so to say unsafe code “is in fact checked” is at least a little misleading. The user still needs to do additional checking for memory errors in unsafe code.
- cwzwarich 9y agoRust doesn't aim to make it impossible to have memory leaks: https://users.rust-lang.org/t/memory-leaks-are-memory-safe/5288 https://users.rust-lang.org/t/memory-leaks-are-memory-safe/5...
- ben-schaaf 9y agoIt at least eliminates what I'd estimate to be the most common cause of memory leaks (in C): missing a free. Which is the same guarantee that GCs provide.
- oconnor663 9y agoThe story is similar to C++. Almost all allocations are done by types that'll automatically call free in their destructors. But because there's no global GC, it's still possible to leak accidentally by creating a cycle in reference-counted smart pointers.
- fnord123 9y agoThere is still the other most common source of memory leaks: putting data into long living (e.g. 'static) hash tables and having no plan for pruning it.