36 ms·
I daresay any Turing-complete language will be unable to prevent all memory leaks, since the simplest memory leak is just using more memory intentionally and ne
by kbolino 2y ago
I daresay any Turing-complete language will be unable to prevent all memory leaks, since the simplest memory leak is just using more memory intentionally and never letting any of it go. Unless you want to eliminate resizable data structures like linked lists, growable arrays, trees, and hash tables, you can always leak memory.
What Rust and most other modern languages do is make it very difficult to unintentionally and/or unknowingly leak memory. There are times when even this can't be guaranteed without breaking other constraints (e.g. one of the solutions to the setenv unsafety issue involves leaking memory instead), but they are rare and documented.